mysql database migration and version upgrade
Preparations
1. The IP of the server to be migrated: 47.110.157.82, close mysql-5.6.31
2. The IP of the target server to be migrated: 192.186.164.134 and the mysql-5.6.51 database installation package
Database migration
IP: 192.186.164.134 decompress the mysql5.6.51 database installation package
tar -zxvf mysql-5.6.51-linux-glibc2.12-x86_64.tar.gz
Modify the decompressed file name as mysql
mv mysql-5.6.51-linux-glibc2.12-x86_64 mysql
Check if there is a mysql user
id mysql
If it does not exist, add the mysql user
useradd mysql -r -s /bin/false
Set mysql file permissions
chown mysql.mysql -R /usr/local/mysql
Create mysql configuration file
vim /etc/my.cnf
Add content
[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
port=3307
socket=/usr/local/mysql/mysql.sock
log_error=/usr/local/mysql/data/mysql3307.err
Enter the installation directory mysql, mysql start the copy script to the directory init.d
cd mysql
cp support-files/mysql.server /etc/init.d/mysql
Migrate IP: 47.110.157.82 server mysql data directory to IP: 192.186.164.134 server mysql data directory
rsync -av 47.110.157.82:/usr/local/mysql/data/ /usr/local/mysql/data/
Start mysql
service mysql start
Errors may be reported during startup. Please check the /usr/local/mysql/data/mysql3307.err log to resolve.
Access mysql
mysql -S /usr/local/mysql/mysql.sock -uroot -p
Upgrade mysql version
mysql_upgrade -S /usr/local/mysql/mysql.sock -p123456