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即可。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章