MySQL command line SQL data import demo

Source: Internet
Author: User

The following articles mainly introduce the actual operation process of importing SQL data from MySQL command lines. If you are curious about the actual operation process of importing SQL data from MySQL command lines, the following articles will unveil its mysteries.

I personally export abc. sqlftp abc. SQL to the server in the insert mode of UTF-8 to phpmyadmin.

Ssh to server

MySQL-u abc-p use KKK (database name, if not, create database KKK) set names 'utf8' source abc. SQL

Note: I have seen the set character set utf8; statement. It is not feasible. Chinese characters are garbled.

1. First open MySQL in the command line Console

Perhaps the command is as follows:

 
 
  1. MySQL -u root -p database_name 

Then you may be prompted to enter the corresponding Password

2. The following command may be useful to you. When you want to change a database

 
 
  1. MySQL>use database_name 

Run the following command:

 
 
  1. MySQL>source d:\datafilename.sql 

Of course, you need to clarify the path of the file and use it correctly.

Enter bin in the directory where MySQL is installed. Enter the command to import SQL.

For example, import and install your MySQL Command Line in d: \ MySQL

The procedure is as follows:

Start> RUN> Enter CMD

D:

 
 
  1. cd MySQL\bin  
  2. MySQL -u root -p123456 test <d:\a.sql  

Here, root is your MySQL administrator username, and 123456 is the password test is the database name d: \ a. SQL is the location of the backup data file.

For Windows, go to the Bin folder in the MySQL file directory from the command prompt and execute the command

 
 
  1. MySQL -u root -p databasename < db.sql 

Here, root is your MySQL user name, databasename is your database name, and db. SQL: You are a file. note that you must set db. the SQL statement can be placed in the bin folder. of course, the file location can be changed.

For LINUX, enter

 
 
  1. MySQL databasename < db.sql 

The above content is an introduction to SQL data imported from MySQL command lines. I hope you will get some benefits.

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.