I am doing the preparatory work for a great website migration.
The database is about 10 GB in size, and several tables contain> 15 million records. Unfortunately, this only happens in a large single mysqldump file in SQL format due to customer relationships outside my competence, but you know how this happens. My goal is to minimize downtime and therefore import data as quickly as possible.
I tried using the standard MySQL CLI interface like this:
$mysql database_name < superhuge_sql_file -u username -p
It is, however, very slow.
To try to speed things up, I used awk to break the file into pieces for each table with related data and created a small shell script to try to import the tables in parallel, for example:
#!/bin/sh awk '/DROP TABLE/{f=0 ;n++; print >(file="out_" n); close("out_" n-1)} f{ print > file}; /DROP TABLE/{f=1}' superhuge.sql for (( i = 1; i <= 95; i++ )) do mysql -u admin --password=thepassword database_name < /path/to/out_$i & done
It is worth mentioning that this is a "use once and destroy" script (passwords in scripts, etc.).
Now it works, but it still takes more than 3 hours to complete the work on a quad-core server, doing nothing currently. Tables are imported in parallel, but not all of them at once, and trying to get MySQL server information through the CLI is very slow during the process. I'm not sure why, but trying to access tables using the same mysql user account when this happens. max_user_connections is not limited.
I established maximum connections with 500 in my.cnf, but otherwise MySQL did not configure on this server.
I had a good hunt, but I was wondering if there were any MySQL configuration options that would help speed up this process or any other methods that I skipped would be faster.