首页 > 代码库 > CentOS安装MySQL问题汇总
CentOS安装MySQL问题汇总
遇到的错误
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 -pEnter 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 123456Enter password: mysqladmin: connect to server at ‘localhost‘ failederror: ‘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 -pEnter 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 statementmysql> SET PASSWORD = PASSWORD(‘123456‘);Query OK, 0 rows affected (0.03 sec)mysql> create database yan1;Query OK, 1 row affected (0.00 sec)
不懂为什么再设置一遍密码。
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。