Indra Prakash Tiwari
Indra Prakash Tiwari

Reputation: 1057

unable to connect to mysql database in Ubuntu

I'm facing this problem for few days now. I'm trying to connect to my MySQL on Ubuntu machine. But I'm not getting this thru. Please see the following commands that I ran and the error messages.

root@ipadtest:/var/lib/mysql# mysql start

Warning: World-writable config file '/etc/mysql/my.cnf' is ignored ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)

root@ipadtest:/var/lib/mysql# mysql -uroot -p

Warning: World-writable config file '/etc/mysql/my.cnf' is ignored Enter password: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)

root@ipadtest:/var/lib/mysql# mysqld

Warning: World-writable config file '/etc/mysql/my.cnf' is ignored 150821 11:34:38 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!

150821 11:34:38 [ERROR] Aborting

150821 11:34:38 [Note] mysqld: Shutdown complete

root@ipadtest:/var/lib/mysql# mysql restart

Warning: World-writable config file '/etc/mysql/my.cnf' is ignored ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)

root@ipadtest:/var/lib/mysql# mysqladmin -u root -p status

Warning: World-writable config file '/etc/mysql/my.cnf' is ignored Enter password: mysqladmin: connect to server at 'localhost' failed error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)' Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!

Could anyone please tell what is the issue. It seems to me that DB has been corrupted. If yes, then how can I recover? TIA.

Upvotes: 6

Views: 31144

Answers (3)

Bala Murugan
Bala Murugan

Reputation: 479

I resolve this Error By the Below Commands :-

sudo chown mysql:mysql /Applications/XAMPP/xamppfiles/etc/my.cnf

After That Do the 2nd Command:-

sudo chmod 600 /Applications/XAMPP/xamppfiles/etc/my.cnf

It Resolve Me. Anyone face this problem try once with above cmd.

Upvotes: 0

Matt Clark
Matt Clark

Reputation: 28589

The error is very clearly explained in the warning message, it is ignoring your my.cnf.

Warning: World-writable config file '/etc/mysql/my.cnf' is ignored

Try executing the following, and then restarting the server

chown mysql:mysql /etc/mysql/my.cnf
chmod 600 /etc/mysql/my.cnf

This will set the owner of the file to mysql and the permissions 600 will give only the user mysql access to read and write to the file, it will disallow access to all other users.

Upvotes: 23

Axel Amthor
Axel Amthor

Reputation: 11096

Check owner of /etc/mysql/my.cnf that it's actualy mysql and do a

chmod go -rw /etc/mysql/my.cnf
service mysql restart

It's obviously totally ignoring whats configured and trying to connect through local socket which is probably not open.

Upvotes: 6

Related Questions