Original link: https://www.cnblogs.com/operationhome/p/9141881.html
延申, mongodb, mariadb: https://www.cnblogs.com/operationhome/
Once the upgrade process, in this record.
The reason: The new project requires a new database version support.
Upgrade main steps:
Back up the original database --- "Uninstall mariadb ---" Add mariadb domestic source --- yum "to install mariadb ---" initialize the database --- "Import data.
1. Back up the original database
Because it is the database upgrade test environment, small amount of data, export data directly to the database I need to migrate to a sql file.
mysqldump -uroot -p --database database_name >name.sql
2. Uninstall mariadb
Because it is a new Mariadb10.2 installed on the same server, so we need to uninstall the old version.
Uninstall mariadb:
yum remove mariadb
To delete a profile:
rm -f /etc/my.cnf
Delete the data directory:
rm -rf /var/lib/mysql/
3. Add mariadb10.2 domestic yum source
Before I add a foreign source, installation is very time-consuming, so I find domestic yum source , this source by installing faster.
vim /etc/yum.repos.d/Mariadb.repo
Add the following:
[mariadb] name = MariaDB baseurl = https://mirrors.ustc.edu.cn/mariadb/yum/10.2/centos7-amd64 gpgkey=https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB gpgcheck=1
Clear yum source cache data
yum clean all
Generating new source data cache yum
yum makecache all
Yum official source (domestic installation slower)
1
2
3
4
5
6
7
|
# MariaDB 10.2 CentOS repository list - created 2018-06-06 03:42 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http:
//yum
.mariadb.org
/10
.2
/centos7-amd64
gpgkey=https:
//yum
.mariadb.org
/RPM-GPG-KEY-MariaDB
gpgcheck=1
|
Different systems yum official source URL: https: //downloads.mariadb.org/mariadb/repositories/#mirror=tuna
4. Installation mariadb10.2
yum install MariaDB-server MariaDB-client -y
Start and add the boot from Kai:
systemctl start mariadb.service systemctl enable mariadb.service
5. mariadb Initialization
/usr/bin/mysql_secure_installation
General recommendations are configured as follows:
Enter current password for root (enter for none): Just press the Enter button Set root password? [Y/n]: Y New password: your-MariaDB-root-password Re-enter new password: your-MariaDB-root-password Remove anonymous users? [Y/n]: Y Disallow root login remotely? [Y/n]: n Remove test database and access to it? [Y/n]: Y Reload privilege tables now? [Y/n]: Y
6. The imported data to the new version mariadb
method one:
After landing mysql command with a source :( behind with the path of our sql backup file)
source /root/backup/java_api.sql
Method Two:
Directly into the command line
mysql -uroot -p >/root/backup/java_api.sql
The above is the entire upgrade process.