首页 | 新闻 | 交流 | 问吧 | 文档 | 手册 | 下载 | 博客

mysql密码和登录问题

作者:  时间: 2011-06-14

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

解决办法:

#修改数据库root用户口令

# 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/mysqld restart
# mysql -uroot -p
Enter password:

mysql>


#使root用户可以远程登录
GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "mysql";
flush privileges;