mysql 文件导入的终端命令

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9106972/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 11:58:48  来源:igfitidea点击:

terminal command for mysql file import

mysql

提问by rgb

I am trying to import a 60 MB file, filename-20120201.tbz, into a newly created MySQL database. I am using terminal, and have opened the database by the prompt use new_database.

我正在尝试将一个 60 MB 的文件filename-20120201.tbz导入到新创建的 MySQL 数据库中。我正在使用终端,并通过提示使用 new_database 打开了数据库。

How do I import this file correctly? I am on a Mac. Thanks.

如何正确导入此文件?我在 Mac 上。谢谢。

回答by Naveen Kumar

If you are running mysql and using your newly created database use the below code to run the script file

如果您正在运行 mysql 并使用新创建的数据库,请使用以下代码运行脚本文件

mysql> SOURCE input_file

or from terminal

或从终端

mysql -u root -p database < filename-20120201.tbz

回答by Rezigned

Try

尝试

$ mysql -u root -p new_database < db-dump.sql

Where: new_database is the name of your new database and db-dump.sql is the mysql file to be imported

其中: new_database 是新数据库的名称,db-dump.sql 是要导入的 mysql 文件

回答by Tadeck

This should do the trick:

这应该可以解决问题:

\. filename

(provided within MySQL's command line, assuming filenameis SQL file)

(在 MySQL 的命令行中提供,假设filename是 SQL 文件)

回答by Fahim Parkar

Place the password immediately after -p

紧接着输入密码 -p

mysql -u root -ppassword database < file.sql