Sunday, 6 March 2022

Transferring a MySQL Database to another Server

 This should be easy...

On server do:

mysqldump -u osd -p osd > osd_dump_06mar21.sql

But on my very small virtual server I hit an error about conection to mysql being lost.     I had to increase some timeouts in the mysqld configuration file....but I have forgotten which ones - will update this when I remember.


Transfer the dump file to the other server (I use scp).

On the other server, set up the user login details then do:

mysql -u osd -p osd < osd_dump_06mar21.sql

BUT this gave an error:

Unknown collation: 'utf8mb4_0900_ai_ci'

I found (on stack exchange!) that the solution is to replace all occurrences of this string with 'utf8mb4_unicode_ci'

The simplest way to do that is with sed:

sed -i 's/utf8mb4_0900_ai_ci/utf8mb4_unicode_ci/g' osd_dump_06mar21.sql 

After doing that the import:

mysql -u osd -p osd < osd_dump_06mar21.sql

worked fine.