6

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.

1
  • service mysqld restart and then tried? Commented Aug 21, 2015 at 6:04

3 Answers 3

23

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.

8
  • I have down this.. and now file permission looks alike .. -rw------- 1 mysql mysql 3579 Aug 21 09:54 /etc/mysql/my.cnf ... Do I need to restart mysql now? mysql restart or something else? Commented Aug 21, 2015 at 6:14
  • That is how it should look, now do as you said, service mysql restart and let me know how it works.
    – Matt Clark
    Commented Aug 21, 2015 at 6:15
  • it says ... stop: Unknown job: mysql start: Unknown job: mysql :( Commented Aug 21, 2015 at 6:18
  • I executed show databases command, and it says ... root@ipadtest:/var/lib/mysql# show databases The program 'show' is currently not installed. You can install it by typing: apt-get install nmh root@ipadtest:/var/lib/mysql# Commented Aug 21, 2015 at 6:19
  • without service.. it says... root@ipadtest:/var/lib/mysql# mysql restart ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111) Commented Aug 21, 2015 at 6:20
6

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.

2
  • fixing file permission didn't help Commented Aug 21, 2015 at 6:30
  • getting error -- test@ipadtest:~$ mysql restart ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) Commented Aug 21, 2015 at 9:04
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.