Since the system is migrated to the government affairs cloud (centos system), mysql vulnerabilities are often scanned, and it is necessary to upgrade mysql from time to time. The previous upgrade method was very rough. First, backup-delete the original database-import the backup data. Use the method of copying the data directory and find that it is in normal use, so as to make a record. To install mysql in linux environment, please refer to https://www.cnblogs.com/secretmrj/p/15600144.html#page_end_html
My original database installation directory:
/usr/local/mysql
Data file address:
/usr/local/mysql/data
Here's how the operation begins:
1. New version download address:
MySQL :: Download MySQL Community Server
Select the version to download:
2. Upload to the cloud server:
Copy it to /usr/local/ and decompress it with the following command:
# .tar.gz suffix
tar -zxvf filename
# .tar.xz suffix
tar -Jxvf filename
3. Stop mysql service
service mysql stop
4. Back up the original system (/usr/local):
mv /usr/local/mysql /usr/local/mysql_bak
5. Rename the directory decompressed in the second step
mv mysql-8.0.32-linux-glibc2.12-x86_64 mysql
6. Copy the original data to the new directory
cp -rf /usr/local/mysql_bak/data /usr/local/mysql
7. Change mysql/data permissions
chown -R mysql:mysql /usr/local/mysql/data
chmod -R 750 /usr/local/mysql/data
chown -R mysql. /usr/local/mysql
8. Start the mysql service
service mysql start
Sometimes the error of The server quit without updating PID file will appear, use the following command to find the mysql process, and use kill -9 process ID, and then re-run service mysql start
ps -ef |grep mysql