How to connect with MySQL server if it won't connect via the socket?

Posted by cwd on Server Fault See other posts from Server Fault or by cwd
Published on 2011-06-27T01:22:46Z Indexed on 2011/06/27 8:24 UTC
Read the original article Hit count: 224

Filed under:
|
|
|

I have an account on a shared server. I have jailshell access and also PhpMyAdmin.

I want to run mysql commands via SSH but I'm getting an error:

$ mysql -u mySqlUser -p mySqlPw
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

I can connect with PHP and phpMyAdmin, so would it be possible to call mysql from the shell and have it connect via an ip and port instead of the socket? The file /var/lib/mysql/mysql.sock does not exist - maybe that is intentional, and the only thing in /etc/my.cnf is

[mysqld]
skip-innodb

More Info

I don't have access to change system settings. I did a search in /var for mysql.sock but found nothing. However, phpMyAdmin might be connecting via a socket somehow:

Image

Really it would just be great if I could connect via IP.

Also tried these two syntaxes:

$ mysql -u mySqlUser -p mySqlPw -h localhost
$ mysql -u mySqlUser -p mySqlPw -h localhost -P 3306

Both with the same result:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

© Server Fault or respective owner

Related posts about linux

Related posts about mysql