How to Switch the Default Version of MySQL/MariaDB
In some cases, you may need to upgrade or switch the version of MySQL/MariaDB to take advantage of new features or security updates. This article will detail how to switch the default version of MySQL/MariaDB in the ServBay environment. Here are the specific steps:
TIP
The following example will use migrating from MariaDB 10.11 to MariaDB 11.3
1. First Backup the Old Database Version
Before switching the MariaDB version, it is recommended to back up the current database to prevent data loss. You can easily back up all databases using the mysqldump
command.
mysqldump -uroot -p --all-databases --opt > mariadb_backup.sql
When executing the above command, the system will prompt you to enter the root user's password for MariaDB. Once the backup is complete, you will find a file named mariadb_backup.sql
in the current directory.
2. Install the New Version You Want to Use, Such as MariaDB 11.3
In the management panel of ServBay, find the database management section, select MariaDB, and click to install the desired new version (for example, MariaDB 11.3).
3. Disable the Old Version, Such as 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 (for example, MariaDB 10.11) and disable it.
4. Enable the New Version and Ensure the Service is Running Properly
After disabling the old version, enable the new version of MariaDB and ensure its service is running properly.
5. Switch the Default Version from MariaDB 10.11 to MariaDB 11.3 in the Settings Panel, Click Apply
Next, you need to 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. Go Back to the Service Panel to See the Default Version Has Been 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. In the Command Line, Enter mysql -V
to See the Version Has Been Switched to 11.3.2
Enter the following command in the command line to confirm that the MariaDB version has been switched successfully:
mysql -V
The output should show the current MariaDB version as 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 you to enter the root user's password for MariaDB. Once the password is entered, the database will start to restore.
9. Confirm the Database Has Fully Restored
To ensure the database has fully restored, you can log into MariaDB and check if the data is complete:
mysql -uroot -p
After logging in, you can use the following command to view the list of databases:
SHOW DATABASES;
Check each database and table to ensure the data is complete and accurate.
Through the above steps, you have successfully switched the default version of MariaDB to a new version and restored the database. We hope this article helps you smoothly complete the switch of MariaDB versions.