LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock (https://www.linuxquestions.org/questions/linux-software-2/cant-connect-to-local-mysql-server-through-socket-var-lib-mysql-mysql-sock-281557/)

emir.cortes 04-25-2012 02:45 PM

I had the same problem on a virtual machine running Ubuntu. After reading allenhighnote message, I realized my silly mistake.
I had changed the file: /etc/mysql/my.cnf to set bind-address to the IP that at that moment the virtual machine had, but when the DHCP assigned another IP the my.cnf was no longer valid.

Solution: I changed the bind-address.

jeffpeck 08-26-2012 06:35 PM

You need to make sure MySQL is running:

sudo /etc/init.d/mysqld start

codymham 05-06-2013 01:40 PM

Worked
 
Running /etc/init.d/mysqld start worked for me.
I guess mysql had stopped.

KazaJhodo 07-05-2013 11:31 AM

Most Common Cause
 
There are various things that can cause this issue- obviously since we have so many different solutions being presented. I troubleshoot sites for a living and this is what I find to be the most common reason for this error.


When sql runs it creates temp files, one of these is the sock file mentioned within this error. Within your my.cnf file it is specified where sql attempts to find/write this file.

First check your system to see where my.cnf is, if you can't find it- its because sql is not running and hasn't ran in the past. Check the path specific in your my.cnf, then check the owners on that directory. Usually this happens because the owners permissions are not quite right. Such as a mysql:root ownership.

To fix it, simply run a chown mysql:mysql directoryname. Restart sql, service restart mysql, /etc/init.d/mysql restart, /etc/init.d/mysqld restart - usually one of those variations on linux.

Hopefully this helps save some time. As I said there are numerous reasons, I find this is the most common. Especially if you've moved the install to another server.

Pineiden 03-06-2014 07:19 AM

Hello, i solved that:

1.- In my.cnf changue 'localhost ip' to your IP (where you have your site installed)
2.- In mysql environment (when you access by mysql -u root -p) you give access to users not using 'localhost', use your IP.
3.- In your 'settings' or 'configuration' file (if you are using Wordpress, drupal,etc) you have to change 'loccalhost' for 'Your IP'

Then you have a correct conecction.

I think if you ddeactivate innodb it loss sense use mysql beacuse it's designed for innodb


All times are GMT -5. The time now is 02:54 PM.