解决 ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket ‘/tmp/mysql.sock‘ (2)

1.ubuntu安装mysql默认用户名和密码:

sudo cat /etc/mysql/debian.cnf

2.ubuntu修改root密码

先登录超级管理员,即步骤一的用户名和密码。

use mysql;
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';

3. 登录报错&&但是sudo可以正常登录:

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

解决办法:

sudo vim /etc/mysql/my.cnf
添加以下内容:

[mysqld]
socket=/tmp/mysql.sock
[client]
socket=/tmp/mysql.sock

重启mysql服务
service mysql restart

此时问题解决

你可能感兴趣的:(安装,mysql,adb,数据库)