mysql 5.7忘记密码及重新更改目录,无相关文件

mysql更改配置后,数据库存储目录更改,mysql出现

mysqld: Table 'mysql.plugin' doesn't exist

2018-06-14T08:14:22.143907Z 0 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2018-06-14T08:14:22.149103Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-06-14T08:14:22.150239Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key
2018-06-14T08:14:22.150267Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2018-06-14T08:14:22.150363Z 0 [Note] IPv6 is available.
2018-06-14T08:14:22.150383Z 0 [Note]   - '::' resolves to '::';
2018-06-14T08:14:22.150431Z 0 [Note] Server socket created on IP: '::'.
2018-06-14T08:14:22.151913Z 0 [Warning] Insecure configuration for --pid-file: Location '/opt/website/mysql/var' in the path is accessible to all OS users. Consider choosing a different directory.
2018-06-14T08:14:22.152119Z 0 [Warning] Failed to open optimizer cost constant tables
2018-06-14T08:14:22.152321Z 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
2018-06-14T08:14:22.152403Z 0 [ERROR] Aborting

[root@RCD var]#  ./mysql_install_db --basedir=/opt/website/mysql --datadir=/opt/website/mysql/var/ --user=mysql

[root@chen ~]# /etc/rc.d/init.d/mysql stop

[root@RCD bin]# ./mysqld_safe --skip-grant-tables &

[root@RCD bin]# mysql -p

mysql> update mysql.user set authentication_string=password('123') where user='root' and Host = 'localhost';

mysql> flush privileges;

mysql> quit

[root@RCD bin]# /etc/rc.d/init.d/mysql restart

[root@RCD bin]# mysql -uroot -p

mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> SET PASSWORD = PASSWORD('123');
Query OK, 0 rows affected, 1 warning (0.00 sec)

猜你喜欢

转载自blog.csdn.net/chen_jianjian/article/details/80694874