本帖最后由 diyle 于 2011-08-11 21:55:16 编辑

解决方案 »

  1.   

    grant all privileges on *.* to abcd@'%' identified by '123456';执行一下上面这句就可以了
      

  2.   

    用ROOT登录上去检查一下这个用户的权限show grants FOR 'abcd'@'localhost' 
      

  3.   


    运行结果:
    mysql> grant all privileges on *.* to abcd@'%' identified by '123456';
    Query OK, 0 rows affected (0.08 sec)执行后,还是连不上,继续追问
      

  4.   

    mysql> show grants FOR 'abcd'@'localhost';
    ERROR 1141 (42000): There is no such grant defined for user 'abcd' on host 'localhost'为啥米?
      

  5.   

    删了这条记录,重新创建一个吧,不知道你怎么创建的。
    grant all on database.table to user@'%' identified by 'password'
      

  6.   

    使用 root 登录看看如下语句的结果:
    select user, host from mysql.user;
      

  7.   


    我又重新创建了一次,上次是用phpmyadmin直接建的,这次是用mysql命令如下:mysql> CREATE USER 'abcd'@'%' IDENTIFIED BY '123456';
    Query OK, 0 rows affected (0.02 sec)mysql> grant all privileges on *.* to 'abcd'@'%';
    Query OK, 0 rows affected (0.00 sec)mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)mysql> select user,host from mysql.user;
    +------+-----------+
    | user | host      |
    +------+-----------+
    | abcd | %         |
    | root | 127.0.0.1 |
    |      | localhost |
    | pma  | localhost |
    | root | localhost |
    +------+-----------+
    5 rows in set (0.00 sec)连接依然报Access denied for user 'abcd'@'localhost'
    我又重新修改了下密码
    mysql> update user set password=password('123456') where user='abcd';
    Query OK, 1 row affected (0.00 sec)
    Rows matched: 1  Changed: 1  Warnings: 0mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)还不行。mysql> CREATE USER 'abcd'@'%' IDENTIFIED BY '123456';
      

  8.   

     CREATE USER 'abcd'@'192.167.0.6' IDENTIFIED BY '123456';
    grant all privileges on *.* to 'abcd'@'%';
    试试
      

  9.   

    or
    CREATE USER 'abcd'@'localhost' IDENTIFIED BY '123456';
      

  10.   


    咦,这样可以,咋%不行。如何使任意host都能连呢
      

  11.   

    你的$hostname = "localhost";修改为你的服务器IP
      

  12.   

    or
    $hostname = "你的服务器名"
      

  13.   

    这个问题让我搁置了好久,闲来重新装了下amp.久试发现是mysql版本的问题。一直没搞明白mysql.5.5.+的版本默认不支持tcp/ip连接?
    我重新下了个5.1.58 社区版的,一切ok!
    好了,散分结贴!