Solving the problem of Mysql importing large data file with SQL statement _mysql
Source: Internet
Author: User
For people who often use MySQL, phpMyAdmin is a necessary tool. This tool is very powerful and can perform almost all database operations, but it also has a weakness that can be very slow to import large data files to a remote server, or even a long unresponsive situation.
Why is there such a situation? When we select an SQL data file and submit it, the server first uploads the file to the server before executing the import code to import the data into the database. We know that phpMyAdmin is uploaded through the web of data files, and the Web upload is very unstable, especially when the speed is slow, which is why we have so many times in front of the computer, and ultimately there is no result of the reason.
Through the above analysis, we know that this problem is out of the web upload rather than the importer program, so if you can avoid uploading the web through the problem is a good thing to do. We may think of that powerful FTP upload tool, but phpMyAdmin cannot select the file on the remote server, which is very depressing.
Here we are going to discard the phpmysqladmin and import the database through the MySQL statement. Many people wonder how to execute SQL statements, which is a key issue that requires your space to support SSH (Secure Shell Protocol), and you'll need some Linux commands.
First login to the server via SSH (I use the Putty Login tool), find our SQL file with some simple Linux commands, and run the following code:
MySQL Db_name < Data_file.sql
If there are no prompts after the command is executed, our data has been imported successfully (note that the file format is Date_file.sql and sql.gz will be wrong in Chinese).
——————— –2008.12.9 Update ———————-
Sometimes you may run into error messages and say that you don't have enough permissions, so we need to add some parameters.
After this, you will be prompted to enter the password, and then enter your database password can be imported.
Parameter-h is the server that specifies the import,-U is the user name of the database,-P is the password for the login database, and the three parameters are not followed by a space.
——————— –2008.12.9 Update ———————-
This is a good idea, but not all people can use this method, because the premise is your space must support SSH login, and support SSH login space is relatively few, this is very regrettable.
There is another way is to phpmyadmin inside the import that function module to extract, a little change can also achieve the same effect. Of course, if you are a master of PHP, you can also write an import program, you can directly select a server path, look forward to ing ...
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service