linux版本为:Red Hat Enterprise Linux Server release 6.4
wget https://repo.mysql.com//mysql57-community-release-el6-10.noarch.rpm
rpm -ivh mysql57-community-release-el6-10.noarch.rpm
yum install -y mysql-community-server
Dependencies Resolved
==================================================================================================================
Package Arch Version Repository Size
==================================================================================================================
Installing:
mysql-community-server x86_64 5.7.23-1.el6 mysql57-community 153 M
Installing for dependencies:
mysql-community-client x86_64 5.7.23-1.el6 mysql57-community 23 M
mysql-community-common x86_64 5.7.23-1.el6 mysql57-community 332 k
mysql-community-libs x86_64 5.7.23-1.el6 mysql57-community 2.1 M
Transaction Summary
==================================================================================================================
Install 4 Package(s)
Total download size: 178 M
启动时显示初始化失败:
[root@redhat2 ~]# service mysqld start
初始化 MySQL 数据库: [失败]
mysql版本为:5.7.23
查看报错日志:
2018-09-02T04:16:07.681689Z 1 [ERROR] Failed to open the bootstrap file /var/lib/mysql-files/install-validate-password-plugin.Gkohex.sql
2018-09-02T04:16:07.681704Z 1 [ERROR] 1105 Bootstrap file error, return code (0). Nearest query: 'LSE SET @sys.tmp.table_exists.SQL = CONCAT('SELECT COUNT(*) FROM `', in_db, '`.`', in_table, '`'); PREPARE stmt_select FROM @sys.tmp.table_exists.SQL; IF (NOT v_error) THEN DEALLOCATE PREPARE stmt_select; SET out_exists = 'TEMPORARY'; END IF; END IF; END;
'
2018-09-02T04:16:07.681866Z 0 [ERROR] Aborting
################################
两种解决方式:
方法1.vi /tmp/mysql-init.txt
UPDATE mysql.user SET authentication_string = PASSWORD('p@ssw0rd')
WHERE User = 'root' AND Host = 'localhost';
FLUSH PRIVILEGES;
通过 mysqld_safe启动
:
mysqld_safe --init-file=/tmp/mysql-init.txt
重启检查密码设置是否生效:
service mysqld stop
service mysqld start
chkconfig mysqld on
Test root's password with mysql CLI:
mysql -u root -p
方法2:mysql安全模式 通过skip-grant-tables跳过设置,启动后再设置密码:
killall -TERM mysqld
mysqld_safe
--skip-grant-tables &
mysql> use mysql
update user set authentication_string=PASSWORD('
123456
') where user='
root
';
mysql> FLUSH PRIVILEGES;