摘要:本文主要向大家介绍了MySQL数据库之MySQL笔记-最简单的方法来解决找不到mysqld.sock文件的问题 ,通过具体的内容向大家展现,希望对大家学习MySQL数据库有所帮助。
本文主要向大家介绍了MySQL数据库之MySQL笔记-最简单的方法来解决找不到mysqld.sock文件的问题 ,通过具体的内容向大家展现,希望对大家学习MySQL数据库有所帮助。
首先,环境:ubuntu 14.04,采用apt-get的方式安装的,手动安装可能路径设置稍有区别。
1、安装MySQL后,用命令行首次启动时发现找不到Mysqld.sock文件,提示:
ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock‘ (2),如图:
2、网上的方法很多不实用,这里介绍一种最简单的方法来解决这个问题。
# sudo /etc/init.d/mysql restart
3、弯路:
root@pc:/# mysql -uroot -p
Enter password:
ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock‘ (2)
root@pc:/opt#
cd /var/run/mysqld/
root@pc:/var/run/mysqld#
ls
root@pc:/var/run/mysqld#
里面是空的,缺少了MySQL-client?
root@pc:/var/run/mysqld#
apt-get install mysql-client
root@pc:/opt#
cd /var/run/mysqld/
root@pc:/var/run/mysqld#
ls
还是没东西,换命令启动:
root@pc:/var/run/mysqld#
service mysqld start
mysqld:
unrecognized service
寻找到问题的根源在:/etc/mysql/my.cnf里
root@pc:/etc#
cd mysql/
root@pc:/etc/mysql#
ls
conf.d
debian.cnf debian-start my.cnf
root@pc:/etc/mysql#
vim my.cnf
这里有有关mysqld.sock的设置,MySQL按照这个默认设置去找时,没有找到。
如果更改这里的路径问题会很麻烦,因此采用下面的办法解决问题:
root@pc:/#
sudo /etc/init.d/mysql restart
*
Stopping MySQL database server mysqld
[ OK ]
*
Starting MySQL database server mysqld
[ OK ]
*
Checking for tables which need an upgrade, are corrupt or were
not
closed cleanly.
root@pc:/#
mysql -uroot -p
Enter
password:
Welcome
to the MySQL monitor. Commands end with ; or \g.
Your
MySQL connection id is 43
。。。。。。
Type
‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input
statement.
mysql>
OK,解决了
本文由职坐标整理并发布,希望对同学们学习MySQL有所帮助,更多内容请关注职坐标数据库MySQL数据库频道!
您输入的评论内容中包含违禁敏感词
我知道了
请输入正确的手机号码
请输入正确的验证码
您今天的短信下发次数太多了,明天再试试吧!
我们会在第一时间安排职业规划师联系您!
您也可以联系我们的职业规划师咨询:
版权所有 职坐标-一站式IT培训就业服务领导者 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
沪公网安备 31011502005948号