How to import SQL files in linux (use command line to transfer mysql database) _ MySQL

Source: Internet
Author: User
Tags ftp client
How to import SQL files in linux (use command line to transfer mysql database) bitsCN.com

Export SQL files

Use phpmyadmin to export the database as an SQL file at your original website service provider.

Upload SQL files

As mentioned above, we have not installed ftp on the cloud host. how can we upload it?

Open the ftp client software, such as filezilla, and use the server IP address and root password. during connection, you must use SFTP to connect to linux. Note: This method is not safe, but we do not have ftp here. if you want to upload local files to the server, there is no better and faster way.

Upload database. SQL to the/tmp directory.

Connect to linux and log on to mysql

Use putty to connect to the VM instance. The usage of putty is not described here.

After the connection, log on to mysql


> Mysql-u root-p
> Password:

Note: If you have created another mysql user, you can select the appropriate user to log on. You can learn about mysql command lines elsewhere.

Import the uploaded SQL into the database

Follow the three steps below to quickly import the SQL file

Mysql> use yourdatabasename;
Mysql> set names utf8;
Mysql> source/tmp/database. SQL;

Then, the screen will be rolled continuously, and the prompt is displayed, indicating that the import is successful.

Finally, delete database. SQL.

BitsCN.com

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.