admin管理员组

文章数量:1532656

今天想登陆下mysql查询一下数据,结果发现客户端连接不上,报错提示:2003-Can’t connect to MySQL server on local(10061 “Unkown error”),然后进入到linux 里的mysql,一样连接不上, 报错提示:解决ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’。

然后也在网上查询了一些方法:这里给各位汇总一下(少,请莫见怪)

ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var mysql 启动不了 - adolfmc - 博客园

Can’t connect to local MySQL server through socket的解决方法 - thebestrule - 博客园

mysql Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ - THISISPAN - 博客园

解决Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’错误_似水流年-CSDN博客

解决数据库Can’t connect to MySQL server on ‘localhost’ (10061)的问题_我的光荣的博客-CSDN博客

解决can’t connect to MySQL server on ‘localhost’(10061)问题_sanqima的专栏-CSDN博客

Can’t connect to MySQL server on ‘localhost’ (10061) - Stack Overflow

然鹅,这些都不适合我,我注意到其中有个说,报这样的错“Can’t connect to local MySQL server through socket”,意味着socket这个文件不存在,但是我的目录下是的确存在的(日期是5月31号)

所以我索性把这个文件删掉, 再重新建一个相同名字的文件。

修改时间是今天拉,也就是7月20号。然后输入命令,尝试登陆本机mysql: (发现已经没有再报错了)

$ ./bin/mysql --socket=~/local/mysql/mysql_3308.sock -uroot password *****

./bin/mysql  Ver 14.14 Distrib 5.6.40, for Linux (x86_64) using  EditLine wrapper
Copyright (c) 2000, 2018, 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.

Usage: ./bin/mysql [OPTIONS] [database]
  -?, --help          Display this help and exit.
  -I, --help          Synonym for -?
  --auto-rehash       Enable automatic rehashing. One doesn't need to use
                      'rehash' to get table and field completion, but startup
                      and reconnecting may take a longer time. Disable with
                      --disable-auto-rehash.
                      (Defaults to on; use --skip-auto-rehash to disable.)

现在开启mysql服务:

$ nohup ./bin/mysqld_safe --defaults-file=~/local/mysql/myf &
[1] 10449
nohup: 忽略输入并把输出追加到"nohup.out"

$ ps
  PID TTY          TIME CMD
10449 pts/13   00:00:00 mysqld_safe
10630 pts/13   00:00:00 mysqld
10909 pts/13   00:00:00 ps
32009 pts/13   00:00:00 bash

$ 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.40-log Source distribution

Copyright (c) 2000, 2018, 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> 

再登陆就没有问题了。

---------- 如果这篇文章对您有帮助,请您随手点个赞,谢谢啦~~~~ ---------

本文标签: connectLocalErrortmpmysqlsock