14

I have a MySQL server running on Amazon EC2 in a VPC instance. I had to change the instance type of it to handle load and when I brought it back up, the socket didn't exist anymore. The file /var/run/mysqld/mysqld.sock doesn't exist and nor does the directory.

I have no idea where it went, but it is just gone. So is there a way to fix that? If so how? The server is running Ubuntu 10.04.

Dave Long
  • 349
  • 1
  • 4
  • 15

1 Answers1

16

Confirm that mysqld.sock doesn't exist

sudo find / -type s | grep mysqld.sock

Check that your /etc/mysql/my.cnf file agrees that the file should be /var/run/mysqld

socket  = /var/run/mysqld/mysqld.sock

and if it does then

sudo mkdir -p /var/run/mysqld
sudo chown mysql /var/run/mysqld/
sudo service mysql restart

but I suspect your problem lies elsewhere as the mysql start script will create the directory if it doesn't exist. Is there any relevant message in your mysql logs ?

djoe
  • 5
  • 2
user9517
  • 114,104
  • 20
  • 206
  • 289
  • Well that seemed to fix everything. I think the problem was that I was using mysqld and /etc/init.d/mysql start to start the server, but I never tried the service method. That was the only one that would create the directory and socket. – Dave Long Aug 25 '11 at 22:37
  • 1
    bizarrely, i get this every time i enter my server. and every time i must apply this solution to fix it. would be great if there were some permanent fix. – john-jones Jul 30 '15 at 10:42
  • I got an error like "error: Found option without preceding group in config file: /etc/mysql/my.cnf at line: 24 Fatal error in defaults handling. Program aborted" – Blairg23 Feb 22 '18 at 03:25
  • Thanks ..i have same problem , i edited /etc/mysql/my.cnf file and added socket = /var/run/mysqld/mysqld.sock , mysql server working started after restrat . – Bhagvat Lande Mar 28 '20 at 17:28
  • 1
    find: ‘/run/user/1000/gvfs’: Permission denied – hu7sy Nov 23 '21 at 09:13