Pagina 1 di 2

Problema MySql

Inviato: sab 13 nov 2010, 14:44
da rfringuello89
Salve a tutti, quando avvio mysql ottengo questo errore:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock' (2)

Non riesco a darmi pace in quanto qualche tempo fa ero riuscito a configurarlo e accedevo al prompt tranquillamente. Avevo trovato una guida in cui c'erano alcuni comandi e mi avevano permesso di farlo funzionare, ora dopo aver formattato non trovo più tale guida. Vi prego di aiutarmi! Grazie

PS se avvio il demone da /etc/rc.d in questo modo: sh /etc/rc.d/rc.mysqld ottengo:

101113 14:42:44 mysqld_safe Logging to '/var/lib/mysql/darkstar.err'.
chown: invalid user: `mysql'
101113 14:42:44 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
101113 14:42:44 mysqld_safe mysqld from pid file /var/run/mysql/mysql.pid ended

Re: Problema MySql

Inviato: sab 13 nov 2010, 14:51
da 414N
Ma hai letto cosa c'è scritto all'inizio del file rc.mysqld?
rc.mysqld ha scritto: # To start MySQL automatically at boot, be sure this script is executable:
# chmod 755 /etc/rc.d/rc.mysqld

# Before you can run MySQL, you must have a database. To install an initial
# database, do this as root:
#
# mysql_install_db --user=mysql
#
# Note that the mysql user must exist in /etc/passwd, and the created files
# will be owned by this dedicated user. This is important, or else mysql
# (which runs as user "mysql") will not be able to write to the database
# later (this can be fixed with 'chown -R mysql.mysql /var/lib/mysql').
#
# To increase system security, consider using "mysql_secure_installation"
# as well. For more information on this tool, please read:
# man mysql_secure_installation
Tra l'altro, dovresti farlo partire così

Codice: Seleziona tutto

sh /etc/rc.d/rc.mysqld start

Re: Problema MySql

Inviato: sab 13 nov 2010, 18:03
da rfringuello89
Si ovviamente lo avvio come mi hai postato. E eseguendo i comandi per settare la password utente ottengo sempre l'errore che ho postato nel primo messaggio.
Per esempio anche se avvio: mysql_secure_installation inserisco la password e ottengo:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock' (2)

subito dopo mi viene riproposto di inserire la password:
Enter current password for root (enter for none):

Se qualcuno mi potesse aiutare dicendo l'esatta procedura di configurazione diciamo da dopo l'installazione del pacchetto sarei davvero molto grato

Re: Problema MySql

Inviato: sab 13 nov 2010, 18:10
da 414N
rfringuello89 ha scritto:E eseguendo i comandi per settare la password utente ottengo sempre l'errore che ho postato nel primo messaggio.
Quale password utente?
Nello script è scritto che per far funzionare correttamente il demone mysqld lanciato da rc.mysqld deve essere presente nel sistema (quindi in /etc/passwd) l'utente mysql. Può anche non avere nessuna password.
Te la cavi con un

Codice: Seleziona tutto

useradd mysql

Re: Problema MySql

Inviato: sab 13 nov 2010, 18:13
da targzeta
Hai seguito le indicazioni dello script? Qui neongen ha postato una parte rilevante:
viewtopic.php?f=1&t=32632&p=285908l#p285769

Emanuele

Re: Problema MySql

Inviato: sab 13 nov 2010, 18:59
da rfringuello89
Allora, l'utente mysql è presente nel mio sistema. Per accedere a mysql prima usavo la sintassi mysql -u root -p e inserivo poi la password. Se lancio
sh /etc/rc.d/rc.mysqld start
ottengo comunque questo:

101113 18:55:54 mysqld_safe Logging to '/var/lib/mysql/darkstar.err'.
101113 18:55:54 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
101113 18:56:02 mysqld_safe mysqld from pid file /var/run/mysql/mysql.pid ended

e se provo a avviare mysql -u root ottengo:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock' (2)

Re: Problema MySql

Inviato: sab 13 nov 2010, 21:05
da targzeta
Scusa se mi ripeto, ma l'hai letto il post che ti ho linkato prima?

Emanuele

Re: Problema MySql

Inviato: sab 13 nov 2010, 21:53
da rfringuello89
si che l'ho visto ma alla fine il problema dell'utente era che mancava il pacchetto! io il pacchetto ce l'ho! Vorrei solo ritrovare quella guida che avevo trovato in rete

Re: Problema MySql

Inviato: sab 13 nov 2010, 22:10
da targzeta
Io ti avevo detto di vedere la risposta di neongen, lì viene postato parte dello script per fa partire il server MySQL. In pratica una volta che hai installato il pacchetto devi anche configurare un minimo il server, come prima cosa devi creare l'utente proprietario del server e poi dargli una password, tutte cose scritte nel post di neongen che ti ho linkato. Se poi guardi l'output del comando che hai dato e leggi il file '.err' vedrai che ti spiega perchè il server si ferma.

Codice: Seleziona tutto

101113 18:56:02 mysqld_safe mysqld from pid file /var/run/mysql/mysql.pid ended
Emanuele

Re: Problema MySql RISOLTO

Inviato: sab 27 nov 2010, 20:56
da rfringuello89
Salve ragazzi ho ritrovato quella famosa guida:
http://php.html.it/guide/lezione/2508/c ... slackware/

dopo aver dato quei banali comandini funziona perfettamente.. Il problema era sicuramente dovuto a una questione di permessi. Grazie ancora a tutti voi

Re: Problema MySql

Inviato: mar 3 lug 2012, 20:38
da darkstaring
Seraaaa...
Anche io avrei lo stesso problema...

Codice: Seleziona tutto

root@:francesco$ sh /etc/rc.d/rc.mysqld restart

root@:francesco$ 120703 19:22:53 mysqld_safe Logging to '/var/lib/mysql/darkstar.err'.
120703 19:22:53 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
120703 19:22:54 mysqld_safe mysqld from pid file /var/run/mysql/mysql.pid ended


root@:francesco$ mysql -u root -p
Enter password: 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock' (2)

root@:francesco$ ls -al /var/run/mysql/ 
total 8
drwxr-xr-x  2 mysql mysql 4096 Jul  3 19:22 .
drwxr-xr-x 27 root  root  4096 Jul  3 19:20 ..

root@:francesco$ mysql_install_db --user=francesco
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h darkstar password 'new-password'

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!


Leggendo /var/lib/mysql/darkstar.err, trovo i seguenti errori

Codice: Seleziona tutto

root@:francesco$ cat /var/lib/mysql/darkstar.err | grep ERROR
120630  9:22:39 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
120630  9:22:41 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
120703  9:47:28 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
120703  9:47:31 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
120703 19:20:52 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
120703 19:20:56 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
120703 19:22:53 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
120703 19:22:54 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
Come posso aggiungere mysql.host???

GraZie Francesco

Re: Problema MySql

Inviato: mar 3 lug 2012, 21:03
da ermes
non vorrei sbagliare ma credo che vi manchi il cambio di owner e gruppo alle directory /var/run/mysql/ prima di lanciare il "mysql_install_db"

se non interpreto male l'inizio del file rc.mysqld i problemi dovrebbero essere risolti con il seguente comando:
#cd /var/run/
#chown -R mysql mysq

io poi mi ricordo che avevo eseguito anche questo:
#chgrp -R mysql mysq

ciao

Re: Problema MySql

Inviato: mar 3 lug 2012, 21:41
da targzeta
Ma hai provato ad eseguire

Codice: Seleziona tutto

mysql_upgrade
come scritto nel log? Dovrevve risolvere lui questi problemi.

Emanuele

Re: Problema MySql

Inviato: mar 3 lug 2012, 23:10
da darkstaring
Ho provato ad eseguire entrambi i comandi ma sembra non andare anzi gli errori sono aumentati:

Codice: Seleziona tutto

root@:run$ cat /var/lib/mysql/darkstar.err | grep ERROR
120630  9:22:39 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
120630  9:22:41 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
120703  9:47:28 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
120703  9:47:31 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
120703 19:20:52 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
120703 19:20:56 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
120703 19:22:53 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
120703 19:22:54 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
120703 21:54:46 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
120703 21:54:48 [ERROR] /usr/libexec/mysqld: Can't find file: './mysql/host.frm' (errno: 13)
120703 21:54:48 [ERROR] Fatal error: Can't open and lock privilege tables: Can't find file: './mysql/host.frm' (errno: 13)
120703 22:03:14 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
120703 22:03:16 [ERROR] /usr/libexec/mysqld: Can't find file: './mysql/host.frm' (errno: 13)
120703 22:03:16 [ERROR] Fatal error: Can't open and lock privilege tables: Can't find file: './mysql/host.frm' (errno: 13)
120703 22:03:54 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
120703 22:03:56 [ERROR] /usr/libexec/mysqld: Can't find file: './mysql/host.frm' (errno: 13)
120703 22:03:56 [ERROR] Fatal error: Can't open and lock privilege tables: Can't find file: './mysql/host.frm' (errno: 13)
120703 22:06:09 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
120703 22:06:11 [ERROR] /usr/libexec/mysqld: Can't find file: './mysql/host.frm' (errno: 13)
120703 22:06:11 [ERROR] Fatal error: Can't open and lock privilege tables: Can't find file: './mysql/host.frm' (errno: 13)
Ho eseguito i comandi detti da voi, ho cambiato solo il comando
#chown -R mysql mysq
in
#chown -R mysql mysql

Codice: Seleziona tutto

root@:run$ sh /etc/rc.d/rc.mysqld restart

root@:run$ 120703 22:06:09 mysqld_safe Logging to '/var/lib/mysql/darkstar.err'.
120703 22:06:09 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
120703 22:06:11 mysqld_safe mysqld from pid file /var/run/mysql/mysql.pid ended


root@:run$ mysql_upgrade 
Looking for 'mysql' as: mysql
Looking for 'mysqlcheck' as: mysqlcheck
Running 'mysqlcheck with default connection arguments
mysqlcheck: Got error: 2002: Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock' (2) when trying to connect
FATAL ERROR: Upgrade failed

Re: Problema MySql

Inviato: gio 5 lug 2012, 12:34
da darkstaring
Nessuno sà aiutarmi?
Posto l'output dei vari permessi e gruppi

Codice: Seleziona tutto

root@:etc$ ls -al /var/run/ | grep mysql
drwxr-xr-x  2 mysql     mysql     4096 Jul  5 10:26 mysql

root@:etc$ cat passwd group | grep mys
mysql:x:27:27:MySQL:/var/lib/mysql:/bin/false
mysql:x:27:

In /etc/mysql non trovo un file di configurazione e non riesco ad andare avanti...
Ho eliminato la directory che conteneva i database e non la trovo più.. mi date il percorso???"
vorrei controllare i permessi...
:evil:

Cosa posso fare? mi servirebbe now() :)