Tuesday, April 15, 2025

moving a MySQL database from one host to another

We had earlier moved a Moodle install from one server to another, and now wanted to move its database also to localhost.

Using this to set up mysql, creating database + user, and later testing a connection - 

sudo mysql -p worked for logging in as root user.

create database our_master_db;

CREATE USER 'our_db_admin'@'%' IDENTIFIED BY 'OurPassword';
GRANT ALL ON our_master_db.* TO 'our_db_admin'@'%';

to export and restore dbs.

date; mysql -h 127.0.0.1 -u our_db_admin -p our_master_db < our_master_db.OldServerdb-2024.15-04-2025.sql; date

This showed that it completed in some 20 minutes. After that, needed to change the connection settings and port in Moodle's config.php

No comments:

Post a Comment