Linux Mysql首次启动报错

装好mysql后总是提示错误信息:

[root@localhost ~]# mysql -u root -p
Enter password:

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

解决方法:

# /etc/init.d/mysql stop 
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking & 
# mysql -u root mysql 
mysql> update user set Password=PASSWORD('新密码') where USER='root'; 
mysql> flush privileges; 
mysql> quit 
# /etc/init.d/mysql restart 
# mysql -uroot -p 
Enter password: (输入刚刚的新密码)
mysql>

此时想用下SQL语句,结果弹出:

ERROR 1820 (HY000): You must SET PASSWORD before executing this statement

再设置一次密码就可以了:

mysql> SET PASSWORD =PASSWORD('新密码');

猜你喜欢

转载自waisam.iteye.com/blog/2108998