Get the App
SLTechnology News&Howtos  ›  Computer Software News  › 

Linux system how to import sql file method linux import sql file command code

Shulou Source: shulou.com Published: 2022-05-31 10:39:09 11月25日 Update

Linux import sql file command to share with you, many users have just come into contact with the linux system, and Windows is completely different from the use of computers, do you feel a headache?

Upload sql files

As mentioned earlier, we have not installed ftp on the CVM, how can we upload it?

Open ftp client software, such as filezilla, and use the server IP and root and password. Be sure to connect in SFTP mode when connecting, so that you can connect to linux. Note that this method is not secure, but we do not have ftp here, and there is no better and faster way to upload local files to the server.

We upload database.sql to the / tmp directory.

Connect to linux and log in to mysql

Use putty to connect to the cloud host. The use of putty will not be introduced here.

After connecting, log in to mysql

The code is as follows:

> mysql-u root-p

> password:

Note that if you have previously established other mysql users, you can choose the appropriate user to log in. You can learn about the command line of mysql elsewhere.

Import the uploaded sql into the database

Follow these three steps to quickly import the sql file

The code is as follows:

Mysql > use yourdatabasename

Mysql > set names utf8

Mysql > source / tmp/database.sql

Then the screen will keep scrolling, and finally prompt that the import is successful.

Finally, remember to delete the database.sql.

Tags: File method user login code command host server service system different appropriate headache security success three continuous usage place customer Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Linux Huawei Microsoft Shulou Information