Importing Large SQL Files via SSH Without Using phpMyAdmin
When moving your website to another server or restoring a backup, if the size of your database file with .sql extension is high (Ex: 200 MB and above), when you try to upload via the phpMyAdmin panel, the browser freezes or due to the server's PHP limits (upload_max_filesize / max_execution_time). "Script timeout" you will get error. By exceeding this limit, you can use Linux SSH commands to import SQL files larger than GB in seconds.
SQL Import Process via SSH Step by Step:
- First, upload your backup .sql file to the main directory of your site (It doesn't matter, it can be under the root directory or `/home/` folder) via FileZilla or your panel's file manager. Make sure the filename is simple (Ex:
yedek.sql). - Open the Putty program and connect to your server. root Connect as.
- Log in to the folder where you uploaded the file with the terminal command:
cd /home/kullaniciadi/public_html - To commit the database directly to the MySQL core, run this magic command:
mysql -u veritabanı_kullanıcı_adı -p veritabanı_adı < yedek.sql - When you type the command and press Enter, the system will ask for a password. to this area your database user's password Type it and press Enter again. *(Note: For security reasons, letters or asterisks will not appear on the terminal screen while typing the password; type your password correctly and press Enter.)*
Depending on the file size, the process will take between a few seconds and a few minutes. When the terminal line becomes empty again (A new command line appears), the import process has been completed without any errors or losses.
This article is specially prepared for PvPServer.