ERROR 2002 (HY000): Can't connect to local MySQL server through socket

nianzhang747 2010-09-20 09:16:40
[root@linuxServer ~]# mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

如何解决?
...全文
918 12 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
xilaianzxsc 2010-09-20
  • 打赏
  • 举报
回复
问题是远程连接没问题
feixianxxx 2010-09-20
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 nianzhang747 的回复:]
问题解决了

1.#ps -A|grep mysql
显示类似:
1829 ? 00:00:00 mysqld_safe
1876 ? 00:00:31 mysqld
2.#kill -9 1829
3.#kill -9 1876
4.#/etc/init.d/mysql restart
5.#mysql -u root -p
[/Quote]
直接指定端口号可以么?
ACMAIN_CHM 2010-09-20
  • 打赏
  • 举报
回复
启了两个MYSQL服务?
nianzhang747 2010-09-20
  • 打赏
  • 举报
回复
问题解决了

1.#ps -A|grep mysql
显示类似:
1829 ? 00:00:00 mysqld_safe
1876 ? 00:00:31 mysqld
2.#kill -9 1829
3.#kill -9 1876
4.#/etc/init.d/mysql restart
5.#mysql -u root -p
hehe4569 2010-09-20
  • 打赏
  • 举报
回复
mysql --protocol=TCP -uroot -p -P3306 -hlocalhost

试试看
nianzhang747 2010-09-20
  • 打赏
  • 举报
回复
问题是远程连接没问题 本体连接登陆则出现该问题 也无法重启mysql服务
nianzhang747 2010-09-20
  • 打赏
  • 举报
回复
很简单 可以在server 端创建一个用户 授予权限
然后再远程用该创建的用户登陆
执行
show slave status;

看看是否权限加上了

我的没加上

mysql> show slave status;
ERROR 1227 (42000): Access denied; you need the SUPER,REPLICATION CLIENT privilege for this operation
nianzhang747 2010-09-20
  • 打赏
  • 举报
回复
C:\Documents and Settings\nian.zhang>mysql --protocol=TCP -u 'nian.zhang' -p -P3306 -h10.10.1.101
Enter password: *******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 187
Server version: 5.1.31-community-log MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>


客户端也没问题
nianzhang747 2010-09-20
  • 打赏
  • 举报
回复

[root@linuxServer etc]# mysql --protocol=TCP -uroot -p -P3306 -hlocalhost
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 184
Server version: 5.1.31-community-log MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>
没问题
hehe4569 2010-09-20
  • 打赏
  • 举报
回复
你的socket文件丢失了吧
mysql --protocol=TCP -uroot -p -P3306 -hlocalhost
这个试过了么?
nianzhang747 2010-09-20
  • 打赏
  • 举报
回复
我用root 用户也说没有权限啊 why?


mysql> select current_user();
+----------------+
| current_user() |
+----------------+
| root@% |
+----------------+
1 row in set (0.01 sec)

mysql> show binary logs;
ERROR 1227 (42000): Access denied; you need the SUPER privilege for this operation
nianzhang747 2010-09-20
  • 打赏
  • 举报
回复
新问题又出来了
mysql> show grants for 'nian.zhang' \G;
*************************** 1. row ***************************
Grants for nian.zhang@%: GRANT SELECT, UPDATE, DELETE, CREATE, DROP, INDEX, SUPER, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'nian.zhang'@'%' IDENTIFIED BY PASSWORD '*5CCE2565AAAC88BA466E2EC67E7362AA8C050981'
1 row in set (0.00 sec)

我给远程用户授予权限了
可是还是登陆不上去 查看log
100920 11:51:53 [Note] Slave I/O thread: Failed reading log event, reconnecting to retry, log 'on.000001' at postion 357
100920 11:51:53 [ERROR] Error reading packet from server: Access denied; you need the REPLICATION SLAVE privilege for this operation ( server_errno=1227)

这是为什么?

56,940

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧