How to Switch the Default Version of MariaDB
In certain situations, you may need to upgrade or switch the version of MariaDB to take advantage of new features or security updates. This article will detail how to switch the default version of MariaDB in a ServBay environment. Here are the specific steps:
TIP
The example below will demonstrate migrating from MariaDB 10.11 to MariaDB 11.3
1. Backup the Old Version Database First
Before switching MariaDB versions, it is recommended to back up the existing database to prevent data loss. Using the mysqldump
command, you can conveniently back up all databases.
mysqldump -uroot -p --all-databases --opt > mariadb_backup.sql
When executing the above command, the system will prompt for the MariaDB root user's password. After the backup is complete, you will have a file named mariadb_backup.sql
in the current directory.
2. Install the Required New Version, for Example, MariaDB 11.3
In the ServBay management panel, go to the database management section, select MariaDB, and click to install the required new version (e.g., MariaDB 11.3).
3. Disable the Old Version, for Example, MariaDB 10.11
After installing the new version, you need to disable the old version to ensure the system uses the new version of MariaDB. Find the old version (e.g., MariaDB 10.11) and disable it.
4. Enable the New Version and Confirm the Service is Running Normally
After disabling the old version, enable the new version of MariaDB and ensure its service is running correctly.
5. In the Settings Panel, Switch the Default Version from MariaDB 10.11 to MariaDB 11.3, and Click Apply
Next, switch the default version to the newly installed version in the settings panel. Select MariaDB 11.3 and click Apply to apply the changes.
6. Return to the Service Panel to See that the Default Version is Set Successfully
In the service panel, you should be able to see that the default version has been successfully switched to MariaDB 11.3.
7. Return to the Command Line and Enter mysql -V
to See the Version Switch to 11.3.2
Enter the following command in the command line to confirm that the MariaDB version has been successfully switched:
mysql -V
The output should show that the current MariaDB version is 11.3.2.
8. Restore the Database
After switching versions, you need to restore the previously backed-up database. Use the following command to restore the database:
mysql -uroot -p < mariadb_backup.sql
The system will prompt for the MariaDB root user's password. After entering the password, the database restoration will begin.
9. Confirm the Database is Fully Restored
To ensure that the database is fully restored, log in to MariaDB and check if the data is complete:
mysql -uroot -p
After logging in, you can use the following command to view the database list:
SHOW DATABASES;
Check the various databases and tables to ensure the data is complete and accurate.
Through the above steps, you have successfully switched the default version of MariaDB to the new version and restored the database. I hope this article helps you successfully complete the MariaDB version switch.