Error connect to mysql server in ubuntu 12.04

情到浓时终转凉″ 提交于 2020-01-25 04:34:12

问题


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


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/20535492/error-connect-to-mysql-server-in-ubuntu-12-04

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!