Use MySQL to import External SQL files for execution.

Source: Internet
Author: User
When using MySQL to import External SQL files for execution, you need to import External SQL statements to MYSQL for execution. However, on the Character interface, it is impossible to paste all SQL statements into the character interface for execution. Now there are two options: 1) Use a GUI editing software similar to SQLSERVER.

When using MySQL to import External SQL files for execution, you need to import External SQL statements to MYSQL for execution. However, on the Character interface, it is impossible to paste all SQL statements into the character interface for execution. Now there are two options: 1) Use a graphical editing software similar to SQL SERVER, this is really true.

Use MySQL to import External SQL files for execution.
In many cases, External SQL statements must be imported into MYSQL for execution. However, on the Character interface, all SQL statements cannot be pasted into the character interface for execution, there are two options:
1) Use a graphical editing software similar to SQL SERVER. This is really good, easy to use, and intuitive. For example, Mysql Front and Mysql Admistrator are widely used, however, there is a serious problem here. Although it is not a problem for countries that also use English, it is quite difficult for us here. Chinese records cannot be inserted, especially Mysql Admistrator, the character display problem occurs when you enter data in the interface. Mysql Front is better, and I think it is more user-friendly. If your data does not need to be input into Chinese, I recommend using Mysql Front.

2) If the first method cannot solve the problem, you can only use another method. I checked a Mysql help document and said that the command "source "Or "/. ", Both of them can be used. You can try it: Write a test. SQL file in the root directory of drive C. The content is as follows:

Use db

Create table tt (int id, name char (50 ));
Insert into tt values (1, 'sda ');
Insert into tt values (2, 'sgh ');
No matter what commands are used, external files cannot be imported. I thought the command from MYSQL was wrong. Today, we really need to import data. There are several hundred entries, so it is impossible for me to input them one by one. In that case, it is a word: miserable. There is no way to open the character and enter "source c: test. SQL". The record will flash in front of you. That is the word: Shuang.

Later I analyzed one, mainly data. the SQL statements are all inserted statements. If "create" and "use" are not used, it means that the insert statement can be done in this way. However, this is not my fault. I found one on the Internet. Many people are asking this question, but there is no solution, at least I didn't see it. If the Mysql help documentation or an example is provided, very is good.

==================================

Note: This is an article written in. When such an operation went wrong, it should be related to the MYSQL version used at that time, the preceding problem does not occur when using MYSQL with more than 5 o'clock versions.

MYSQL can execute External SQL files in the following way, for example, my testing system is linux:

/Opt/lampp/bin/mysql-uusername-ppassword <sqlfile. SQL

On Windows, I have not tested this import. The principle should be the same. On Windows, I mainly use source to log in and import data.

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.