I am getting the following error when I try to connect to mysql:
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
Is there a solution for this error? What might be the reason behind it?
I am getting the following error when I try to connect to mysql:
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
Is there a solution for this error? What might be the reason behind it?
MariaDB, a community developed fork of MySQL, has become the default implementation of MySQL in many distributions.
So first you should start,
If this fails rather try,
Then to start mysql,
As of today, in Fedora the package is named
mariadb
And in Ubuntu it is calledmariadb-server
.So you may have to install it if its not already installed in your system.
try
Just rain into the same problem -- and here's how I addressed it.
Assuming mysqld is running, then the problem might just be the mysql client not knowing where to look for the socket file.
The most straightforward way to address this consists in adding the following line to your user's profile .my.cnf file (on linux that's usually under /home/myusername):
If you don't have a .my.cnf file there, then create one containing the following:
In my case, since I moved the mysql default data folder (/var/lib/mysql) in a different location (/data/mysql), I added to .my.cnf the following:
Hope this helps.
If your file my.cnf (usually in the etc folder) is correctly configured with
you can check if mysql is running with the following command:
try changing your permission to mysql folder. If you are working locally, you can try:
that solved it for me
Note that while mysql reads the info of the location of the socketfile from the my.cnf file, the mysql_secure_installation program seems to not do that correctly at times.
So if you are like me and shuffle things around at installationtime you might get into the situation where you can connect to the database with mysql just fine, but the thing can not be secured (not using that script anyway).
To fix this the suggestion from sreddy works well: make a softlink from where the script would expect the socket to where it actually is. Example:
(I use /tmp/ as a default location for sockets)
This is a problem if you are running out of disk space. Solution is to free some space from the HDD.
Please read more to have the explanation :
If you are running MySQL at LINUX check the free space of HDD with the command disk free :
if you are getting something like that :
Then this is the problem and now you have the solution!
Since mysql.sock wants to be created at the mysql folder which is almost always under the root folder could not achieve it because lack of space.
If you are periodicaly give the ls command under the mysql directory (at openSUSE 11.1 is at /var/lib/mysql) you will get something like :
The mysql.sock file appearing and disappearing often (you must to try allot with the ls to hit a instance with the mysql.sock file on folder).
This caused by not enough disk space.
I hope that i will help some people!!!! Thanks!