Environment
MySQL is installed on CentOS and needs to be upgraded.
The MySQL version is
mysql> select version();+-----------+| version() |+-----------+| 5.1.73 |+-----------+1 row in set (0.00 sec)
The CentOS version is
lsb_release -aLSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarchDistributor ID: CentOSDescription: CentOS release 6.9 (Final)Release: 6.9Codename: Final
Download new version
Access https://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/ and download the rpm file corresponding to the CentOS version.
This RPM modifies the library file for subsequent Yum installations.
Login Required.
I downloaded themysql57-community-release-el6-11.noarch.rpm
installation process
Install rpm
rpm -Uvh mysql57-community-release-el6-11.noarch.rpm
Install MySQL
yum repolist enabled | grep mysql#yum install -y mysql-community-server#service mysqld start
Installation succeeded, but failed to start.
Resolve Startup Failure issues
mysql.user table is damaged. Please run mysql_upgrade
Found solutions
删除/var/lib/mysql下的三个文件:ibdata1、ib_logfile0、ib_logfile1;然后使用如下命令,重新初始化mysqlmysqld --initialize --user=mysql
When the last command is executed, it appears:
2017-12-14T01:50:57.809614Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.2017-12-14T01:50:57.809639Z 0 [ERROR] Aborting
It looks like there are data files that you want to delete manually.
MySQL configuration file is/etc/my.cnf
It defines the location of the data file and the log file.
datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.socksymbolic-links=0log-error=/var/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pid
Delete all files in the data directory
#rm -rf /var/lib/mysql/*
Reinitialization of MySQL
#mysqld --initialize --user=mysql
Start MySQL, success.
#service mysqld start
Modify the MySQL configuration file /etc/my.cnf to add
[client] default-character-set = utf8mb4 [mysql] default-character-set = utf8mb4 [mysqld] character-set-client-handshake = FALSE character-set-server = utf8mb4 collation-server = utf8mb4_unicode_ci init_connect=‘SET NAMES utf8mb4‘
Restart MySQL, success.
#service mysqld restart
Java Database connection
Revision changed to
jdbc:mysql://1.1.1.1:3306/hhtd_wechat?zeroDateTimeBehavior=convertToNull&&autoReconnect=true
Attention, don't characterencoding.
MySQL Version upgrade