我的mysql是6.0版的,操作系统是WinXP,在控制台里登陆mysql,发现只用用户名可以登陆,不用输密码,进去后操作正常,但是如果用用户名+密码的方式登陆就出错(用户是我用root账户建的,是有密码的,root账户用密码同样登陆不了,所有登陆均在本地进行),下面是Windows控制台里的提示信息,用户名为zwdnet,密码我确定没输错。麻烦大家帮忙看看,是还要怎么设置吗?谢谢!C:\Documents and Settings\Administrator>mysql -u zwdnet -p
Enter password: **********
ERROR 1045 (28000): Access denied for user 'zwdnet'@'localhost' (using password:
 YES)C:\Documents and Settings\Administrator>mysql -u zwdnet
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 6.0.10-alpha-community MySQL Community Server (GPL)Type 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql>

解决方案 »

  1.   

    显然没设置密码啊!一个账户不可能有两个密码吧!
    登录进去后
    set password=password('password');
    退出,用新密码登录。
      

  2.   

    谢谢,可是还是出错
    [code]
    mysql> set password = password('123456');
    ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'
    mysql> quit
    Bye
    [/code]
      

  3.   

    用ROOT进去后看一下你的select user,host,password from mysql.user;贴出来看一下。
      

  4.   

    mysql> set password = password('123456');
    ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'
    mysql> quit
    Bye
      

  5.   

    mysql> quit
    ByeC:\Documents and Settings\Administrator>mysql -u root
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 15
    Server version: 6.0.10-alpha-community MySQL Community Server (GPL)Type 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql> select user,host,password from mysql.user;
    +--------+-----------+------------+
    | user   | host      | password   |
    +--------+-----------+------------+
    | root   | localhost |            |
    | root   | 127.0.0.1 |            |
    |        | localhost |            |
    | zwdnet | localhost | (****)这是密码,我略了 |
    +--------+-----------+------------+
    4 rows in set (0.63 sec)mysql>
      

  6.   

    | root   | localhost |            |
    | root   | 127.0.0.1 |            |
    |        | localhost |            |
    这几个账号的密码为空贴一下
    select current_user();
    show grants;检查一下你当前的身份是什么?
      

  7.   

    安装的时候设置了密码的,以后就是新建了个用户,其它就没动过。mysql> select current_user();
    +----------------+
    | current_user() |
    +----------------+
    | root@localhost |
    +----------------+
    1 row in set (0.09 sec)mysql> show grants;
    +---------------------------------------------------------------------+
    | Grants for root@localhost                                           |
    +---------------------------------------------------------------------+
    | GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
    +---------------------------------------------------------------------+
    1 row in set (0.01 sec)mysql>
      

  8.   

    SET PASSWORD FOR 'zwdnet'@'localhost' = PASSWORD('456');一下,然后用456 为密码登录。
      

  9.   

    谢谢,好像还是不行
    mysql> set password for 'zwdnet'@'localhost' = password('456');
    ERROR 1133 (42000): Can't find any matching row in the user table
    mysql> set password for 'zwdnet@localhost' = password('456');
    ERROR 1133 (42000): Can't find any matching row in the user table
    mysql>
      

  10.   

    select user,length(user),host,length(host) from mysql.user;看一下,估计你的用户句后是不是有空格?
      

  11.   

    mysql> select user,length(user),host,length(host) from mysql.user;
    +--------+--------------+-----------+--------------+
    | user   | length(user) | host      | length(host) |
    +--------+--------------+-----------+--------------+
    | root   |            4 | 127.0.0.1 |            9 |
    |        |            0 | localhost |            9 |
    | root   |            4 | localhost |            9 |
    | zwdnet |            6 | localhost |            9 |
    +--------+--------------+-----------+--------------+
    4 rows in set (0.14 sec)mysql>
      

  12.   

    mysql>use mysql;
    mysql>update user set password=password('123456') where user='zwdnet';
    mysql>flush privileges;
    最好把匿名用户也删除了
    mysql>delete from user where user='';
      

  13.   

    有些奇怪, 你贴一下这个的结果。select user,host
    from mysql.user
    where user='zwdnet' and host='localhost';
      

  14.   

    谢谢,成功了!这样改了以后再登陆结果如下:
    C:\Documents and Settings\Administrator>mysql -u zwdnet
    ERROR 1045 (28000): Access denied for user 'zwdnet'@'localhost' (using password:
     NO)C:\Documents and Settings\Administrator>mysql -u zwdnet -p
    Enter password: **********
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 18
    Server version: 6.0.10-alpha-community MySQL Community Server (GPL)Type 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | test               |
    +--------------------+
    2 rows in set (0.00 sec)mysql>
      

  15.   

    也谢谢您,我又退出后用root登陆,结果如下
    C:\Documents and Settings\Administrator>mysql -u root
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 19
    Server version: 6.0.10-alpha-community MySQL Community Server (GPL)Type 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql> select user,host from mysql.user where user = 'zwdnet' and host = 'localh
    ost';;
    +--------+-----------+
    | user   | host      |
    +--------+-----------+
    | zwdnet | localhost |
    +--------+-----------+
    1 row in set (0.08 sec)ERROR: No query specifiedmysql>
      

  16.   

    估计是因为你的这个账号不是用 create user 创建的,是直接 insert into mysql.user 创建的,这样需要用  FLUSH PRIVILEGES; 把信息加载到内存。或者重启你的mysql
      

  17.   

    对,我的zwdnet账号就是用insert into mysql.user创建的,我照网上弄的。呵呵,麻烦您啦!