Cody
Cody

Reputation: 2649

Error connect to mysql server in ubuntu 12.04

I am trying to connect to mysql server in ubuntu 12.04 from terminal using and password empty("")

mysql -u root -p

it throwing error

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

Though i am able to access database successfully from phpmyadmin and there i see there is no password for root in user user table in mysql database.

I am using xampp package

Upvotes: 1

Views: 1320

Answers (2)

uvais
uvais

Reputation: 416

what i can guess about your problem:following

If your file my.cnf (usually in the /etc/mysql/ folder) is correctly configured with

socket=/var/lib/mysql/mysql.sock

you can check if mysql is running with the following command:

mysqladmin -u root -p status

try changing your permission to mysql folder. If you are working locally, you can try:

sudo chmod -R 755 /var/lib/mysql/

that solved it for me

Upvotes: 0

noobdeveloper
noobdeveloper

Reputation: 420

I think the error is the socket file. Where did you install your xampp?

Can you try this,

mysql -u root -p --socket=/opt/xampp/var/mysql/mysql.sock

where opt is your installation directory. Change opt to your installation directory.

edit: Or if you don't want using socket parameter on your mysql command, you can try

ln -s /opt/xampp/var/mysql/mysql.sock /var/run/mysql/mysqld.sock

Thanks.

Upvotes: 2

Related Questions