今天同时问我一个关于mysql的问题,记录一下
错误提示:
root@localhost ~]# mysql --socket=/tmp/mysql.sock
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
解决方法:
由于mysql 默认的mysql.sock 是在/var/lib/mysql/mysql.sock,但linux系统总是去/tmp/mysql.sock查找,所以会报错
[root@localhost ~]# find / -name mysql.sock
/var/lib/mysql/mysql.sock
1.直接指定mysql通道
[root@localhost ~]# mysql --socket=/var/lib/mysql/mysql.sock
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 5.0.22
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
2. 创建符号连接:
为mysql.sock增加软连接(相当于windows中的快捷方式)。
ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
eg:
root@localhost ~]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
[root@localhost ~]# ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
[root@localhost ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3 to server version: 5.0.22
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
我觉得这两个方法挺好用的
分享到:
相关推荐
在MySQL服务器的运行过程中,可能会遇到“ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock'”这样的错误。这个错误提示表明,客户端试图通过Unix域套接字(socket文件)...
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2) 的异常。是用dmg直接安装的以为安装包又出现了奇奇怪怪的错误,正欲卸载该版本时找到了我的问题的关键。 解决...
在安装好了MySQL之后,使用了新的配置文件后,MySQL服务器可以成功启动,但在登陆的时候出现了ERROR 2002 (HY000): Can’t connect to local MySQL server through socket,即无法通过socket连接到mysql服务器,同时...
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)
在使用MySQL时,可能会遇到一个常见的错误:“ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’”。这个错误表明客户端无法通过Unix套接字文件与本地MySQL服务器建立...
ERROR 2002: Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (111) 解决办法: /usr/local/mysql/bin/mysqladmin -u root > -S /var/lib/mysql/mysql.sock password 'your.passwd' ...
?php $link=mysql_connect(‘localhost’,’root’,... 运行后报错 Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ 但在 命令行中能进入mysql [root@localhost local]# mysql -u root -p E
MySQL数据库是我们日常运维工作中经常会使用的一个重要组件,它在运行过程中可能会出现各种问题,而错误ERROR 2002 (HY000): Can't connect to local MySQL server through socket是一个比较常见的连接失败错误。...
在MySQL的使用过程中,有时会遇到异常错误"ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)"。这个错误通常表示客户端无法通过套接字文件与MySQL服务器...
ERROR 1130 (HY000): Host ‘localhost’ is not allowed to connect to this MySQL server www.jb51.net 出现原因: mysql只有一个root用户,修改root密码后选了MD5,提交后,重新 登陆出现“Host ‘localhost’ is...
服务器:unbuntu16.04,阿里云 ... ...第一阶段:此时以为再重启...ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' 怎么办呢,看看这个啥文件先,然而查到是这个文
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock'(2) ``` 解决方法是使用以下命令: ``` sudo chown -R _mysql:mysql /usr/local/var/mysql ``` 然后启动 MySql 服务: `...
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysqld.sock' (2) 2、故障分析 查看mysql实例的状态 [root@localhost scripts]# netstat -ntlp | grep 3306 tcp 0 0 :
问题 2:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) 该问题是关于 MySQL 服务无法启动的问题。解决方法是杀死 MySQL 进程,启动 MySQL 服务,并...
#### 问题一:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' - **原因**:通常是 MySQL 服务没有启动导致的。 - **解决办法**:执行命令`service mysql start`来启动 ...
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) ``` 这个错误提示表示 MySQL 服务没有启动。可以使用以下命令启动 MySQL 服务: ``` # /etc/init.d/...
如果出现 `ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)` 错误,这是因为 `/var/lib/mysql` 目录的权限问题。解决方法是更改目录的所有权: ```bash...
如果你遇到“ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)”的错误,可以尝试以下解决方案: 1. 检查MySQL服务是否已启动:`# /etc/rc.d/init.d/...
首先,当你尝试用`mysql -uroot -p`命令登录MySQL,并输入密码后,如果出现`ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)`的错误,这通常意味着MySQL...