码迷,mamicode.com
首页 > 数据库 > 详细

CentOS安装MySQL问题汇总

时间:2014-07-17 22:08:31      阅读:253      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   os   数据   art   

遇到的错误

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

描述:刚安装完MySQL,第一次登陆。

[wangyang@CentOS ~]$ mysql -u root -p
Enter password: #我记得root初始是没密码的,这句直接回车
ERROR 1045 (28000): Access denied for user root@localhost (using password: NO) denied for user root@localhost (using password: NO)

然后我就直接尝试修改MySQL的root密码:

[wangyang@CentOS ~]$ mysqladmin -u root -p password 123456
Enter password: 
mysqladmin: connect to server at localhost failed
error: Access denied for user root@localhost (using password: YES)

问题是什么我没弄清楚,解决方案如下:

[root@CentOS ~]# service mysql stop
[root@CentOS ~]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking & 
[wangyang@CentOS ~]$ mysql -u root mysql 
mysql> UPDATE user SET Password=PASSWORD(’newpassword’) where USER=’root’; #newpassword为root新密码
mysql> FLUSH PRIVILEGES;
mysql> quit
[root@CentOS ~]# service mysql start
[wangyang@CentOS ~]$ mysql -u root -p
Enter password: #输入新密码,OK

You must SET PASSWORD before executing this statement

描述:参考前文利用安全模式成功登陆,然后修改密码,等于给MySql设置了密码。登陆进去后,想创建一个数据库测试下。得到的结果却是:

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

解决方法:

mysql> create database localtest;
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
mysql> SET PASSWORD = PASSWORD(123456);
Query OK, 0 rows affected (0.03 sec)

mysql> create database yan1;
Query OK, 1 row affected (0.00 sec)

不懂为什么再设置一遍密码。

CentOS安装MySQL问题汇总,布布扣,bubuko.com

CentOS安装MySQL问题汇总

标签:style   blog   color   os   数据   art   

原文地址:http://www.cnblogs.com/hellowangyang/p/3851700.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!