ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
2015-10-10 15:45
609 查看
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>
创建符号连接:
为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 默认的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>
创建符号连接:
为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启动的四种方式
- mysql数据库的一些常用命令(一)
- mysql修改字符集utf8
- mysql按时间段查询
- [MySQL] - errno:150
- 连接Mysql提示Can’t connect to local MySQL server through socket的解决方法
- mysql 中文乱码
- mysql上给表增加一个自增长列的脚本
- MYSQL 锁机制 分析
- mysql常用命令
- MySql中的变量
- mysql修改密码
- MySQL5.6-内存占用配置方法
- mysql配置文件my.cnf详解
- MySQL快速复制数据库数据表的方法
- MyBatis操作MySQL中文乱码问题
- 如何修改mysql字符编码
- Mysql 分组聚合实现 over partition by 功能
- MYSQL 源代码编绎脚本
- mysql删除一条数据后id不在连续的解决方法