Can't connect to MySQL

Sheratan

Well-known member
I can't connect to mysql using
Code:
mysql -u root -p

But I can login into phpmyadmin and my forum are running without problem! o_O

Code:
[mysql]

# CLIENT #
port                           = 3306
socket                         = /var/lib/mysql/mysql.sock

[mysqld]

# GENERAL #
user                           = mysql
default_storage_engine         = InnoDB
pid_file                       = /var/lib/mysql/mysql.pid
....

It's Percona 5.6 in Debian 7.

Any thought?
 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
 
First thing.. check your disk space. How much free space do you have.
Second, try logging in with mysql -u root -p -h 127.0.0.1 and see if it works.
Third, make sure the /var/lib/mysql/mysql.sock exists and restart the msyql server and try again.
 
Free space is good. Lots of it. (15GB+)

mysql -u root -p -h 127.0.0.1 did the trick! (y) Care to explain?
 
Indicates problems communicating with the socket itself. Did you check to see if it exists at the location you specified in your my.cnf?
By using the localhost IP you are bypassing the socket entirely.

This is what I have defined in mine
Code:
[client]
socket          = /var/run/mysqld/mysqld.sock
[mysqld_safe]
socket          = /var/run/mysqld/mysqld.sock

[mysqld]
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
Make sure the socket is defined for client, mysqld and mysqld_safe. I'm running the latest Percona on Debian Wheezy on all my servers and I have the above in their my.cnf.
 
The socket is there (/var/lib) but somehow the permission is wrong (root:root) not mysqld:mysqld so it cant connect.
 
Top Bottom