0

Correcting mysql.sock connection error

0 Flares Twitter 0 Facebook 0 Google+ 0 LinkedIn 0 Pin It Share 0 StumbleUpon 0 0 Flares ×

mysql logo1 300x155 Correcting mysql.sock connection error

I write this post over to have a quick access to this tutorial than to promote the blog.

The problem

For Several times this has happened to me, always install a new server, or personal machine. I install mysql , and time to connect:

The solution

Simple and easy, look for the configuration file, my.cnf, make sure it is the same configuration file.

Make a backup of it, to avoid any problem. My use is as ubuntu /etc/mysql/my.cnf

Edit the uncompensated you will get the following lines:

Ensure that the user that is experiencing the error, allowed reading /var/run/mysqld/mysqld.sock

If it does not give permission.

MySQL + PHP

If you are trying to connect with php. And is getting the error, it may be that in your php.ini is set, an socket .

To resolve just open php.ini

This path may vary according to the php you are using, in my case I use lighttpd with php-cgi , and this is the default path.

For those who do not know is how to use php or lighttpd not know, you can take a look here: Enabling PHP on lighttpd without difficulties . Enable it, and see how the fastcgi can be much faster.

After opening the file, search for mysql.default_socket put the correct path, or leave blank.

What’s the use?

The speed difference between the connection is quite large, if you pass the direct path of the socket connects much faster, especially if the socket is in tmpfs.

For those who do not know what is tmpfs, you can learn more at this link: Improving performance of linux

References

mysql – http://www.mysql.com/
php – http://www.php.net/
php – stackoverflow

0 Flares Twitter 0 Facebook 0 Google+ 0 LinkedIn 0 Pin It Share 0 StumbleUpon 0 0 Flares ×

Vinícius Muniz Macêdo

Leave a Reply