Windows 上的 mysql 导入

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1774238/
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 14:34:19  来源:igfitidea点击:

mysql import on windows

mysqlwindowsimport

提问by user80151

I have a MySQL file, db.sql. I have tried to import it using:

我有一个 MySQL 文件,db.sql. 我尝试使用以下方法导入它:

mysql -uroot -p[password] db < db.sql

All I get is a listing of mysql commands, or I get a syntax error. The weird thing is I used this file last week and, as far as I know, I'm doing it the same way.

我得到的只是一个 mysql 命令列表,或者我得到一个语法错误。奇怪的是我上周使用了这个文件,据我所知,我也是这样做的。

I create the database, then in command line enter the above but it's not working. I've tried being inside mysql and just at command line and nothing seems to be working.

我创建了数据库,然后在命令行中输入上述内容但它不起作用。我试过在 mysql 中,只是在命令行中,但似乎没有任何效果。

Is there something I should be doing differently in windows or MySQL5? I don't know how the heck I got it to work the first time...

我应该在 Windows 或 MySQL5 中做一些不同的事情吗?我不知道我是怎么第一次让它工作的......

TIA

TIA

回答by wallyk

Try this instead:

试试这个:

mysql -u root -p
(prompts for password)
use db;
source db.sql

回答by Chayapan Khannabha

I found out it is different to run this command from Windows Command Line (cmd.exe) and Windows PowerShell.

我发现从 Windows 命令行 (cmd.exe) 和 Windows PowerShell 运行此命令是不同的。

Using CMD.exe the command works okay, but in PowerShell I get this error:

使用 CMD.exe 命令可以正常工作,但在 PowerShell 中我收到此错误:

mysql -uroot exampledb < exampledb.sql

The '<' operator is reserved for future use.

'<' 运算符保留供将来使用。

回答by Md. Husain

If you are already logged in the try this it will be very useful, but depend upon the MySQL version, it works on MySQL 5.0

如果您已经登录,请尝试这将非常有用,但取决于 MySQL 版本,它适用于 MySQL 5.0

For log in if you are not already logged in.

如果您尚未登录,请登录。

mysql>[your password]

mysql>[您的密码]

Other wise, use the database to which you want to import the SQLDump file by command.

否则,通过命令使用要导入 SQLDump 文件的数据库。

mysql>use [your database name]

mysql>use [你的数据库名称]

And then give source the database Dump file path as blow command(If not works the copy Dump database file to the bin folder where the MySQL installed for eg. "C:/programfiles/mysql/mqlserver5.0/bin")

然后给源数据库转储文件路径作为吹命令(如果不起作用,将转储数据库文件复制到安装MySQL的bin文件夹中,例如“C:/programfiles/mysql/mqlserver5.0/bin”)

mysql> source [dataBasePath+name.sql or dataBaseName.sql]

mysql> 源 [dataBasePath+name.sql 或 dataBaseName.sql]

回答by jaywon

Not sure if your example was a typo or not, but for starters you need to have a space in between your flags and their values, roughly like this:

不确定你的例子是否有错别字,但对于初学者来说,你需要在你的标志和它们的值之间有一个空格,大致如下:

mysql -u root -p [password] db < db.sql

回答by Jani Kajala

I've been using PHP script called "BigDump": http://www.ozerov.de/bigdump.php

我一直在使用名为“BigDump”的 PHP 脚本:http://www.ozerov.de/bigdump.php

回答by rsus

This perfectly works

这完美地工作

mysql>[your password]

mysql>[您的密码]

Other wise, use the database to which you want to import the SQLDump file by command.

否则,通过命令使用要导入 SQLDump 文件的数据库。

mysql>use [your database name]

mysql>use [你的数据库名称]

And then give source the database Dump file path as blow command(If not works the copy Dump database file to the bin folder where the MySQL installed for eg. "C:/programfiles/mysql/mqlserver5.0/bin")

然后给源数据库转储文件路径作为吹命令(如果不起作用,将转储数据库文件复制到安装MySQL的bin文件夹中,例如“C:/programfiles/mysql/mqlserver5.0/bin”)

mysql> source [dataBasePath+name.sql or dataBaseName.sql]EG: source C:.....sql

mysql> source [dataBasePath+name.sql or dataBaseName.sql]EG: source C:....sql

I am using mysql server 5.5

我正在使用 mysql 服务器 5.5