[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)如何解决?

解决方案 »

  1.   

    问题是远程连接没问题 本体连接登陆则出现该问题 也无法重启mysql服务
      

  2.   

    mysql --protocol=TCP -uroot -p -P3306 -hlocalhost试试看
      

  3.   

    问题解决了
     
     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
      

  4.   

    新问题又出来了
    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)这是为什么?
      

  5.   

    我用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
      

  6.   

    你的socket文件丢失了吧 
    mysql --protocol=TCP -uroot -p -P3306 -hlocalhost
    这个试过了么?
      

  7.   


    [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> 
    没问题
      

  8.   

    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>客户端也没问题
      

  9.   

    很简单 可以在server 端创建一个用户 授予权限
    然后再远程用该创建的用户登陆
    执行
    show slave status;看看是否权限加上了我的没加上mysql> show slave status;
    ERROR 1227 (42000): Access denied; you need the SUPER,REPLICATION CLIENT privilege for this operation