mysql服务启动却连接不上的解决方法
程序员文章站
2022-06-21 08:35:47
mysql服务启动,但是连接不上,如何解决?
登陆报错:
root@localhost:~# mysql -u root -p
enter passw...
mysql服务启动,但是连接不上,如何解决?
登陆报错:
root@localhost:~# mysql -u root -p enter password: error 2002 (hy000): can't connect to local mysql server through socket '/var/lib/mysql/mysql.sock' (2) root@localhost:~# service mysqld restart shutting down mysql.. [ ok ] starting mysql. [ ok ] root@localhost:~# mysql -u root -p enter password: error 2002 (hy000): can't connect to local mysql server through socket '/var/lib/mysql/mysql.sock' (2)
分析原因:
原因不详,知道了补上
解决方案一:
root@localhost:~# find / -name mysql.sock /tmp/mysql.sock root@localhost:~# mysql -u root -p -s /tmp/mysql.sock enter password: welcome to the mysql monitor. commands end with ; or \g. your mysql connection id is 1 server version: 5.6.15-log source distribution copyright (c) 2000, 2011, oracle and/or its affiliates. all rights reserved. oracle is a registered trademark of oracle corporation and/or its affiliates. other names may be trademarks of their respective owners. type 'help;' or '\h' for help. type '\c' to clear the current input statement. mysql>
解决方案二:
root@localhost:~# find / -name mysql.sock /tmp/mysql.sock root@localhost:~# vi /etc/my.cnf [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql # default to using old password format for compatibility with mysql 3.x # clients (those using the mysqlclient10 compatibility package). old_passwords=1 # disabling symbolic-links is recommended to prevent assorted security risks; # to do so, uncomment this line: # symbolic-links=0 # 加上下面的这段代码即可 [mysql] socket=/tmp/mysql.sock [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid root@localhost:~# mysql -u root -p enter password: welcome to the mysql monitor. commands end with ; or \g. your mysql connection id is 3 server version: 5.6.15-log source distribution copyright (c) 2000, 2011, oracle and/or its affiliates. all rights reserved. oracle is a registered trademark of oracle corporation and/or its affiliates. other names may be trademarks of their respective owners. type 'help;' or '\h' for help. type '\c' to clear the current input statement. mysql>
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
上一篇: Mysql元数据如何生成Hive建表语句注释脚本详解
下一篇: Mysql事务处理详解
推荐阅读
-
无线网卡连接不上的图文解决方法
-
mysql连接过多和死掉以及拒绝服务的解决方法
-
mysql出现无法使用、无法启动服务问题的解决方法
-
win7系统安装2个mysql版本后连接不上数据库的问题如何解决?
-
navicat连接不上linux服务器上的mysql的解决办法
-
mysql server 5.5连接不上的解决方法
-
mysql57重新安装后无法再次启动mysql57服务“本地计算机上的MySQL服务启动后停止。某些服务在未由其他服务或程序使用时将自动。”--解决方法
-
mysql 5.7.17 安装教程 附MySQL服务无法启动的解决方法
-
本地电脑WIN10连接阿里云WINDOWS服务器上搭建的MySQL数据库
-
Workbench连接不上阿里云服务器Ubuntu的Mysql解决方法(已测)