问题:
linux,登录mysql报错ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock
解决方法:
第一步:先要进入etc 查看是否存在my.cnf文件
如果存在, 打开看下是否为空; 如果不为空,则添加如下内容:
skip-grant-tables
如果不存在my.cnf文件就链接下载:
wget http://github.itzmx.com/1265578519/kangle/master/mysql/5.6/my.cnf -O /etc/my.cnf
下载过后文件 进入etc下,vi my.cnf 编辑my.cnf, 添加内容: skip-grant-tables
第二步: 重启mysql服务
登录mysql
mysql -uroot -p
直接回车可以不用密码登录,但是系统会提示你让你先更改密码;
上述方法仅供参考, 可能不同的Mysql版本, 会有不同!