centos6.8 mysql5.1 升级至mylsq5.6
备份原数据库
mysqldump -u xxx -p --all-databases > databases.sql
停止mysql
service mysqld stop
卸载mysql
yum remove mysql mysql-*
查看是否有残余的mysql
yum list installed | grep mysql
如果有,删除
yum remove mysql-libs
安装MySQL
yum install mysql-community-server
安装完成后,输入命令查看MySQL版本号
mysql -V
启动mysql
service mysqld start
报错 MySQL Daemon failed to start. 输入命令 初始化mysql
mysqld --initialize
报错:
2019-07-02 16:34:09 0 [Warning] TIMESTAMP with implicit DEFAULT value is depreca ted. Please use --explicit_defaults_for_timestamp server option (see documentati on for more details).
2019-07-02 16:34:09 0 [Note] mysqld (mysqld 5.6.44) starting as process 24442 ...
2019-07-02 16:34:09 24442 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!
2019-07-02 16:34:09 24442 [ERROR] Aborting
2019-07-02 16:34:09 24442 [Note] Binlog end
2019-07-02 16:34:09 24442 [Note] mysqld: Shutdown complete
说明数据文件夹已被创建,直接删除,让mysql自己创建即可,输入命令
rm -rf /var/lib/mysql
删除后,注意:然后不需要再初始化了,直接启动mysql,它会自己初始化,输入命令:
service mysqld start
mysql安装成功后创建的超级用户'root'@'localhost'的密码会被存储在/var/log/mysqld.log,可以使用命令查看密码
grep 'temporary password' /var/log/mysqld.log
恢复备份的数据库
mysql -u root -p < databases.sql
报错
ERROR 1805 (HY000): Column count of mysql.user is wrong. Expected 43, found 39. The table is probably corrupted
因为升级不当导致,执行以下命令即可正常执行命令
mysql_upgrade -uroot -p
修改密码策略
查看密码策略
SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+--------+
| Variable_name | Value |
+--------------------------------------+--------+
| validate_password_check_user_name | OFF |
| validate_password_dictionary_file | | # 规则文件保存路径
| validate_password_length | 8 | # 密码长度
| validate_password_mixed_case_count | 1 | # 整个密码中至少要包含大/小写字母的总个数;
| validate_password_number_count | 1 | # 整个密码中至少要包含阿拉伯数字的个数;
| validate_password_policy | MEDIUM | # 密码的验证强度等级
| validate_password_special_char_count | 1 | # 密码中特殊字符至少的个数
+--------------------------------------+--------+
其中验证等级
0/LOW:只验证长度;
1/MEDIUM:验证长度、数字、大小写、特殊字符;
2/STRONG:验证长度、数字、大小写、特殊字符、字典文件;
修改
set global 项目 = 0;