# service mysql start
# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
# mysql -u root -p
Enter password: 123456
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
# /etc/init.d/mysql stop
Shutting down MySQL.. [ OK ]
# mysqld_safe --skip-grant-tables &
160602 19:38:55 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
# mysql
mysql> use mysql
mysql> update user set password=password("123456") where user="root";
mysql> exit
# /etc/init.d/mysql restart
Shutting down MySQL..160602 19:41:32 mysqld_safe mysqld from pid file /var/lib/mysql/CS4.sz.fonsview.com.pid ended
[ OK ]
Starting MySQL. [ OK ]
[1]+ Done mysqld_safe --skip-grant-tables
# mysql -u root -p
Enter password: 123456
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.29-log
mysql> show databases;
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
mysql> SET PASSWORD = PASSWORD('123456');
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
# chkconfig --list //默认开机启动列表查询
# chkconfig --level 2345 mysql on //设置默认开机启动
mysql 忘记 root 密码
最新推荐文章于 2024-01-09 16:31:16 发布