Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use mysql to import sql files in linux system

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the relevant knowledge of "how to use mysql to import sql files in the linux system". The editor shows you the operation process through an actual case. The method of operation is simple and fast, and it is practical. I hope this article "how to use mysql to import sql files in the linux system" can help you solve the problem.

Upload sql files

Suppose we don't install 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.

This is the end of the introduction of "how to import sql files using mysql in linux system". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 251

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report