I installed LAMP on Ubuntu 12.04 LTS (Precise Pangolin) and then set root password on phpMyAdmin. I forgot the password and now I am unable to login. When I try to chan
In my case it was that the disk was full and mysqld couldn't start anymore.
Try to restart mysql service.
> service mysql restart
or
> service mysql stop
> service mysql start
If it doesn't recognize stop
command then it's definitely the disk space. You should make some space in the partition mysql
is allocated or make the disk larger.
Check the disk space with
> df -h
Somehow the MySQL server process did not create the socket, or the client is looking for the socket in the wrong place.
My first suggestion would be to check if the MySQL server is running. Second suggestion might be, is the MySQL server running on another host? If so, add the -h <hostname>
flag to your MySQL client in the terminal.
If MySQL is indeed running, and running locally, check your my.cnf
file. There should be a line like
socket = /var/run/mysqld/mysqld.sock
See if that matches the socket location that you mentioned in your post.
From experience, I would say the most likely scenario is your MySQL server either is not running at all or is not running on the same host as where you run your MySQL client from the terminal.
Your mysql-server might not be running. Ensure it runs by typing mysql.server start
into the terminal.
I think whenever you get the error
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'
I will recommend first to check whether your mysql
daemon is running... Most of the time it will not running by default. You can check it by /etc/init.d/mysqld status
.
If it's not running then start it first:
.../etc/init.d/mysqld start.
I bet it will 110% work.
I fixed this problem by executing the following command:
mysql.server start
And if you are on a mac and used brew to install mysql, simply use:
brew services start mysql
I just experienced the same issue after I had to restart my production server. I am running Debian 8.1 (Jessie) on a DigitalOcean droplet.
This is what I did to resolve my issue:
Check if the file /var/run/mysqld/mysqld.sock
exists. If it doesn't, manually create it by entering touch /var/run/mysqld/mysqld.sock
(which is what I had to do).
So the MySQL process can use this file. Change ownership of said file by entering chown mysql /var/run/mysqld/mysqld.sock
.
Once '2' has been done, restart the MySQL service by entering service mysql restart
or /etc/init.d/mysql restart
.
After going through the above steps, my issue was solved. I rarely have this issue, and there is probably a better way, so by all means provide constructive feedback if need be :).