问题背景:
之前使用的一套mysql 5.6.25,由于一些原因我进行了清除。大家知道我们第二次执行mysql_install_db初始化数据库时,是不会存储root的临时密码。
那么要进入mysql数据库,就引入如下的一篇文章。
案例过程:
0,以无密码认证方式启动数据库
[root@standbygtid mysql]#nohup mysqld_safe --user=mysql --skip-grant-tables&
1,配置root用户的密码
mysql> set password for 'root'@'localhost'='system';
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
2,刷新修改用户密码的操作到mysql.user表
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
3,修改数据库用户密码,提示密码需要41个字节
mysql> set password for 'root'@'localhost'='system';
ERROR 1372 (HY000): Password hash should be a 41-digit hexadecimal number
4,采用password函数修改用户密码成功
mysql> set password for 'root'@'localhost'=password('system');
Query OK, 0 rows affected (0.00 sec)
5,关闭数据库
[root@standbygtid mysql]#mysqladmin -uroot -psystem shutdown
6,启动数据库
[root@standbygtid mysql]# nohup mysqld_safe --user=mysql&
7,可以用上述配置的数据库用户密码登陆
[root@standbygtid mysql]# mysql -uroot -psystem
Warning: Using a password on the command line interface can be insecure.
Welcome to th