今天安装mysql
,连接MySQL
时报错mysql: [Warning] Using a password on the command line interface can be insecure. ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
通过ls
命令查看,发现/var/run/mysqld
目录并不存在,创建这个文件夹sudo mkdir /var/run/mysqld
,然后修改文件夹的所属者sudo chown mysql:mysql /var/run/mysqld
.
重启MySQL
服务sudo /etc/init.d/mysql restart
再次尝试连接MySQL mysql -uroot -p
, 成功。