Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save niotech/50d15fceb2bd22683ddc0ef28af34414 to your computer and use it in GitHub Desktop.
Save niotech/50d15fceb2bd22683ddc0ef28af34414 to your computer and use it in GitHub Desktop.
Migrate DB from MariaDB 10 to MySQL 8

At MariaDB

Check on source

sudo mysql -u root -p

SHOW databases;

+----------------------------+
| Database                   |
+----------------------------+
| information_schema         |
| mysql                      |
| performance_schema         |
| sys                        |
| acarakupang                |
+----------------------------+
9 rows in set (0.002 sec)

SELECT user, host, password FROM mysql.user;

+---------------------------------+----------------+-------------------------------------------+
| User                            | Host           | Password                                  |
+---------------------------------+----------------+-------------------------------------------+
| root                            | localhost      |                                           |
| acarakupang.                    | IP address     | *                                         |
| mariadb.sys                     | localhost      |                                           |
+---------------------------------+----------------+-------------------------------------------+
9 rows in set (0.001 sec)

quit

Dump the database (sql)

cd ~
mysqldump --opt -Q -u acarakupang -p acarakupang > ~/acarakupang.sql
exit

Copy the sql from server to local

scp user@server:~/acarakupang.sql ~/
                                                                                            100%   10MB   4.8MB/s   00:02

At MySQL

make sure that mysql already correctly install and execute command: sudo mysql_secure_installation

Prepare at MySQL

sudo mysql

create database acarakupang;
create user 'acarakupang'@'localhost' identified by 'acarakupang_password';
grant all privileges on acarakupang.* to 'acarakupang'@'localhost';
flush privileges;
quit;

Import data from SQL dump

mysql -u acarakupang -p acarakupang < ~/acarakupang.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment