Article directory
A friend who works in the e-commerce industry recently installed the VestaCP panel and wanted to import a MySQL database through phpMyAdmin , but kept getting a 500 error and failed to import it after multiple attempts…
The problem might be due to php.ini configuration or other issues, causing phpMyAdmin to take too long to export or import large MySQL files, resulting in PHP timeouts and export/import failures.
Even if the modification improves the memory configuration of the related files, it will not help...
At this point, we can achieve the following via the Linux command line:
- Use MySQL backup command line to quickly export MySQL database;
- Use the MySQL import command line to quickly import MySQL databases.
MySQL export database command
MariaDB backup commands▼
mariadb-dump -u root -p[root_password] [database_name] > dumpfilename.sql
MySQL Backup Commands ▼
mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql
- command does not include symbols []
- Please change "dumpfilename" to your MySQL database file name.
- Note the right arrow > is export.
Extract the .gz MySQL database file
If your MySQL database file is compressed with a .gz suffix, it cannot be imported into the database via the SSH command line.
Before running the command to import the MySQL database, please enter the following .gz unzip command to unzip ▼
gunzip FileName.gz
- Please change "FileName" to the name of your MySQL database archive, for example: xxx.sql.gz
MySQL import database command
MariaDB import command▼
mariadb-dump -u root -p[root密码] [数据库名称] < dumpfilename.sql
MySQL import command ▼
mysql -u root -p[root密码] [数据库名称] < dumpfilename.sql
- command does not include symbols []
- Please change "dumpfilename" to your MySQL database file name.
- Note the left arrow < is import.
More SSH commands for Linux systems can be found here ▼
Hopefully, the article "phpMyAdmin database import error 500? Command line for exporting large MySQL files" shared on Chen Weiliang's blog ( https://www.chenweiliang.com/ ) will be helpful to you.
Feel free to share this article's link: https://www.chenweiliang.com/cwl-707.html
