To migrate a WordPress database using MariaDB to another server, follow these steps:
Step 1: Backup the Existing Database
-
Export the Database:
-
SSH into your current server or use a control panel with database access.
-
Use the
mysqldump
command to export the database:bashmysqldump -u your_username -p your_database_name > database_backup.sql
-
You will be prompted to enter your database password.
-
-
Compress the Backup (Optional):
-
To save bandwidth, you can compress the backup file:
bashgzip database_backup.sql
-
Step 2: Transfer the Backup File to the New Server
-
Using SCP (if both servers have SSH access):
bashscp database_backup.sql.gz username@new_server_ip:/path/to/destination
-
Using FTP:
- Use an FTP client like FileZilla to download the backup file from the old server and upload it to the new server.
Step 3: Import the Database on the New Server
-
Login to the New Server:
- SSH into your new server or use a control panel with database access.
-
Create a New Database:
-
Log in to MariaDB/MySQL:
bashmysql -u your_username -p
-
Create a new database and user:
sqlCREATE DATABASE new_database_name; CREATE USER 'new_username'@'localhost' IDENTIFIED BY 'new_password'; GRANT ALL PRIVILEGES ON new_database_name.* TO 'new_username'@'localhost'; FLUSH PRIVILEGES; EXIT;
-
-
Uncompress the Backup File (if compressed):
bashgunzip database_backup.sql.gz
-
Import the Database:
bashmysql -u new_username -p new_database_name < database_backup.sql
Step 4: Update the WordPress Configuration
- Edit
wp-config.php
:-
Locate the
wp-config.php
file in your WordPress installation directory. -
Update the database details to match the new server:
phpdefine('DB_NAME', 'new_database_name'); define('DB_USER', 'new_username'); define('DB_PASSWORD', 'new_password'); define('DB_HOST', 'localhost'); // Or the IP address of your database server
-
Step 5: Test the Migration
-
Access the WordPress Site:
- Ensure your domain is pointing to the new server.
- Access your WordPress site in a browser to verify it's working correctly.
-
Check for Issues:
- Check for any issues with plugins, themes, or broken links and address them as necessary.
By following these steps, you should be able to successfully migrate your WordPress database using MariaDB to another server.