Uploading large SQL files via cPanel or phpMyAdmin often fails due to timeouts or file size limits. In such cases, the most effective solution is to directly transfer the SQL file to the server via SSH using the mysql
command.
Here's an example command:
mysql -u ekasunucu_db -p'dbsifre' ekasunucu_db < /home/ekasunucu/public_html/ekasunucu_db.sql
Details about this command:
-
-u ekasunucu_db
: This is the database username. -
-p'dbsifre'
: The database password is written within' '
. Quotes are mandatory if the password contains spaces. -
ekasunucu_db
: This is the name of the database where the backup will be loaded. -
< /home/ekasunucu/public_html/ekasunucu_db.sql
: The full path to the backup file on the server must be provided.
Step-by-Step Guide to Uploading SQL Files via SSH
-
Connect to the Server via SSH
ssh root@sunucu_ip
-
Check the File Location
ls -lah /home/ekasunucu/public_html/
Make sure the SQL file is actually in this directory.
-
Prepare Database Information
-
Database name
-
Username
-
Password
-
Upload the Backup File
mysql -u username -p'password' databasename < /file/path/backup.sql
Example:
mysql -u ekasunucu_db -p'PasswordHere' ekasunucu_db < /home/ekasunucu/public_html/ekasunucu_db.sql
-
Check for Errors After the Process is Complete
-
If no error is written to the command line, the upload is successful.
-
Alternatively, you can check the number of tables in the database:
mysql -u ekasunucu_db -p
use ekasunucu_db;
show tables;
Things to Consider
-
If the SQL file is very large, use
screen
ortmux
to prevent the session from disconnecting. -
It is better for security to enter the password interactively after writing
-p
instead of giving the password directly in the command:
mysql -u ekasunucu_db -p ekasunucu_db < /home/ekasunucu/public_html/ekasunucu_db.sql
-
Before transferring the file, the encoding and
CHARSET
compatibility of the file content should be checked.
This method is one of the safest and fastest solutions, especially for high-dimensional database migration operations. It can be easily applied on all servers with SSH access.