数据库中的表打不开了?是什么问题呀?报错:Access denied for user‘root@localhost’(using password:YES)高手指点一下吧?谢谢!

解决方案 »

  1.   

    可能的情况如下:
    1).密码错误
    2).不允许直接使用root用户在编程中进行连接(此时需要另建一个用户来使用)
      

  2.   

    root密码不正确or不允许root从localhost访问数据库
    解决方案1)先关闭mysql数据库服务器,如果服务器开了的话
    2)导航到mysql安装目录的bin下,在命令提示符下输入
    mysqld-nt --skip-grant-tables 。这样用户登陆数据库无需输入密码
    3)重开一个命令提示符
    mysql -uroot 进去。
    在mysql>下输入
    GRANT ALL PRIVILEGES ON *.* TO monty@"%" IDENTIFIED BY 'something' WITH GRANT OPTION; 重启服务器
      

  3.   

    GRANT ALL PRIVILEGES ON *.* TO monty@"%" IDENTIFIED BY 'something' WITH GRANT OPTION;改为root,或者你的数据库用户名
      

  4.   

    方法一:
    # /etc/init.d/mysql stop
    # mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
    # mysql -u root mysql
    mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
    mysql> FLUSH PRIVILEGES;
    mysql> quit# /etc/init.d/mysql restart
    # mysql -uroot -p
    Enter password: <输入新设的密码newpassword>mysql>
    方法二:
    直接使用/etc/mysql/debian.cnf文件中[client]节提供的用户名和密码:
    # mysql -udebian-sys-maint -p
    Enter password: <输入[client]节的密码>
    mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
    mysql> FLUSH PRIVILEGES;
    mysql> quit# mysql -uroot -p
    Enter password: <输入新设的密码newpassword>mysql>