加入收藏 | 设为首页 | 会员中心 | 我要投稿 晋中站长网 (https://www.0354zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

Mysql数据库导入教程及示例

发布时间:2022-10-17 14:31:02 所属栏目:MsSql教程 来源:未知
导读: Backup and Restore operations are important part of the database administration. mysqlimport command is used to load data in file into Mysql or Mariadb servers. Mysql import i

Backup and Restore operations are important part of the database administration. mysqlimport command is used to load data in file into Mysql or Mariadb servers. Mysql import is generally used by providing SQLfile.

备份和还原操作是数据库管理的重要组成部分。 mysqlimport命令用于将文件中的数据加载到Mysql或Mariadb服务器中。 Mysql导入通常通过提供SQLfile来使用。

句法 (Syntax)

Syntax of mysqlimportis like below.

mysqlimport语法如下。

mysqlimport OPTIONS DBNAME FILE

mysqlimport选项DBNAME文件

导入SQL文件(Import SQL File)

The first example is simply importing the data file into mysql database. We will provide the username with -uand insert into database name studentsthe sql file named newstudents.sql.

第一个示例只是将数据文件导入mysql数据库。 我们将提供的用户名与-u并插入到数据库名students的sql文件名为newstudents.sql 。

$ mysqlimport -uroot students newstudents.sql

交互提供密码 (Provide Password Interactively)

We may need to provide the password for the user. We can use -poption to provide the password. In this example we will use user ismailand provide password interactively.

我们可能需要为用户提供密码。 我们可以使用-p选项来提供密码。 在此示例中,我们将使用ismail用户并以交互方式提供密码。

$ mysqlimport -u ismail -p students newstudents.sql

提供明文密码批处理模式 (Provide Password Batch Mode in Clear Text)

Another practical way to provide password is batch mode. But keep in mind this is a security violation for the most of the situations. We will provide the password in cleartext with -poption. In this example the password is sosecret.

提供密码的另一种实用方法是批处理模式。 但是请记住,在大多数情况下,这是违反安全性的行为。 我们将使用-p选项以明文形式提供密码。 在此示例中,密码为sosecret 。

$ mysqlimport -u ismail -p sosecret students newstudents.sql

从Mysql Interactive Shell导入 (Import From Mysql Interactive Shell)

We can use mysql shell in order to import sql files. In order to use mysql interactive shell for sql file import we should open the shell.

我们可以使用mysql shell来导入sql文件。 为了将mysql交互式外壳用于sql文件导入,我们应该打开外壳。

$ mysql -u root -p

选择数据库 (Select Database)

and then we will select the database we want to import given sql file.

然后,我们将选择要导入给定sql文件的数据库。

select students;

指定SQL文件 (Specify SQL File)

and the last step is specifying the sql file with \.operator. The SQL file must be in a compatible format in order to complete import operation successfully.

最后一步是使用\.指定sql文件\. 操作员。 SQL文件必须采用兼容格式mssql数据库导入,以便成功完成导入操作。

\. \home\ismail\newstudents.sql;

LEARN MORE How To Recover or Reset Lost MySQL Password On Linux?

(编辑:晋中站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!