Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'
If you are trying to connect mysql using password or without password
like mysql -uUSERNAME or mysql -uUSERNAME -pPASSWORD
and getting error:-
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
find first socket location
sudo find / -type s
my be location would be /tmp/mysql.sock
just go in the mysql file my.cnf
sudo nano /etc/mysql/my.cnf
and do changes in scocket
port = 3306
socket = /tmp/mysql.sock
[mysqld_safe]
socket = /tmp/mysql.sock
nice = 0
Restart mysql, sudo /etc/init.d/mysql restart
And try login again mysql -uUSERNAME
Hope it will work.
Command to know all the mysql variable
sudo mysqladmin variables
To know mysql socket path
mysqld --verbose --help | grep ^socket
Comments
Post a Comment