如何在 Windows 7 中使用命令行执行大型 MySql 数据插入脚本文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6730111/
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
How to execute large MySql data-insert script file using command line in Windows 7?
提问by Nam G VU
I'm new to MySQL so please guide me through how to do this via command line; I've tried but I get NO logging in the console output and the character set is not utf-8
我是 MySQL 的新手,所以请指导我如何通过命令行执行此操作;我试过了,但我没有在控制台输出中登录,而且字符集不是utf-8
Please help.
请帮忙。
回答by Jacob
mysql -e "source /path-to-backup/backup-file.sql" db_name
or
或者
mysql db_name < backup-file.sql
You probably need -u username -p
, too in your command.
您-u username -p
的命令中可能也需要。
回答by Kerrek SB
Since your SQL script doesn't contain any character set configuration directives, mysql
just runs in its default character set Latin1. To change the default character set, start mysql
like this:
由于您的 SQL 脚本不包含任何字符集配置指令,因此mysql
只需在其默认字符集 Latin1 中运行。要更改默认字符集,请按以下方式开始mysql
:
mysql -e "source /path-to-backup/backup-file.sql" db_name --default-character-set=UTF8
回答by Nomesh DeSilva
C:\<installation_path>>\bin>mysql -u<<user>> -p database_name < your_sql_file.sql
could be used if you are getting access issues like ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: NO)
如果您遇到访问问题,可以使用 like ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: NO)
hope that helps !!
希望有帮助!!