Correcting mysql.sock connection error

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

Resolvendo problema de socket no mysql

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.


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


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

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

Vinicius Muniz

Desenvolvedor php, administrador de servidores, fã de linux. Trabalho na empresa Netmake, na produção do software Scriptcase, e como administrador da empresa de hospedagem Hoo.st.

Deixe uma resposta