mysql5.6简单升级到mysql5.7.28过程

原来使用root用户安装mysql5.6,升级也使用root用户执行rpm -Uvh,这是最简单的方式。mysql5.7安装、升级需要按顺序执行:

rpm -Uvh mysql-community-common-5.7.28-1.el6.x86_64.rpm
rpm -Uvh mysql-community-libs-5.7.28-1.el6.x86_64.rpm
rpm -Uvh mysql-community-client-5.7.28-1.el6.x86_64.rpm
rpm -Uvh mysql-community-server-5.7.28-1.el6.x86_64.rpm
升级安装mysql-community-common报软件冲突,由需要加上参数:
rpm -Uvh mysql-community-common-5.7.28-1.el6.x86_64.rpm --replacefiles

 

 

[root@localhost soft_rpm]# rpm -qa|grep -i mysql
MySQL-client-5.6.19-1.el6.x86_64
MySQL-server-5.6.19-1.el6.x86_64
[root@localhost soft_rpm]# mysql -uroot -proot
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.19 MySQL Community Server (GPL)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select version();
+-----------+
| version() |
+-----------+
| 5.6.19    |
+-----------+
1 row in set (0.02 sec)

[root@localhost soft_rpm]# service mysql stop
Shutting down MySQL.... SUCCESS!

[root@localhost mysql5.7.28]# rpm -Uvh mysql-community-common-5.7.28-1.el6.x86_64.rpm
warning: mysql-community-common-5.7.28-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
        file /usr/share/mysql/bulgarian/errmsg.sys from install of mysql-community-common-5.7.28-1.el6.x86_64 conflicts with file from package MySQL-server-5.6.19-1.el6.x86_64

。。。。。。。。。。。。。。。


[root@localhost mysql5.7.28]# rpm -Uvh mysql-community-common-5.7.28-1.el6.x86_64.rpm --replacefiles
warning: mysql-community-common-5.7.28-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:mysql-community-common ########################################### [100%]
[root@localhost mysql5.7.28]# rpm -Uvh mysql-community-libs-5.7.28-1.el6.x86_64.rpm
warning: mysql-community-libs-5.7.28-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:mysql-community-libs   ########################################### [100%]
[root@localhost mysql5.7.28]# rpm -Uvh mysql-community-client-5.7.28-1.el6.x86_64.rpm
warning: mysql-community-client-5.7.28-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:mysql-community-client ########################################### [100%]
[root@localhost mysql5.7.28]# rpm -Uvh mysql-community-server-5.7.28-1.el6.x86_64.rpm
warning: mysql-community-server-5.7.28-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:mysql-community-server ########################################### [100%]
[root@localhost mysql5.7.28]# rpm -qa|grep -i mysql
mysql-community-libs-5.7.28-1.el6.x86_64
mysql-community-server-5.7.28-1.el6.x86_64
mysql-community-common-5.7.28-1.el6.x86_64
mysql-community-client-5.7.28-1.el6.x86_64
[root@localhost mysql5.7.28]# mysql -uroot -proot
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@localhost mysql5.7.28]# touch /var/lib/mysql/mysql.sock
[root@localhost mysql5.7.28]# chown mysql:mysql /var/lib/mysql/mysql.sock
[root@localhost mysql5.7.28]# service mysqld start
Starting mysqld:                                           [  OK  ]
[root@localhost mysql5.7.28]# mysql_upgrade -uroot -proot -s   #-s 表示只更新系统表
mysql_upgrade: [Warning] Using a password on the command line interface can be insecure.
The --upgrade-system-tables option was used, databases won't be touched.
Checking if update is needed.
Checking server version.
Running queries to upgrade MySQL server.
Upgrading the sys schema.
Upgrade process completed successfully.
Checking if update is needed.
[root@localhost mysql5.7.28]# service mysqld restart
Stopping mysqld:                                           [  OK  ]
Starting mysqld:                                           [  OK  ]
[root@localhost mysql5.7.28]# mysql -uroot -proot
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.28 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select version();
+-----------+
| version() |
+-----------+
| 5.7.28    |
+-----------+
1 row in set (0.01 sec)   

 

附:

非root用户安装参考之前的文章:
https://blog.csdn.net/ohaozy/article/details/103435471
https://blog.csdn.net/ohaozy/article/details/103436139
软件包使用rpm2cpio命令按以上顺序解压操作即可,与mysql5.6不同的是:
5.6初始化数据库执行:mysql_install_db --user=mysql --basedir=/data/mysql/usr --defaults-file=/data/mysql/etc/my.cnf
5.7初始化数据库执行:mysqld --initialize --basedir=/data/mysql/usr --datadir=/data/mysql/data --user=dongzw --log-error=/data/mysql/mysqld.log --pid-file=/data/mysql/mysqld.pid

--user=mysql中的mysql是linux系统上的普通用户名,任意取

非root用户安装升级也很简单,如上解压出rpm包后,覆盖原来路径下的内容,启动mysql,执行mysql_upgrade -uroot -proot -s即可。

你可能感兴趣的:(mysql)