简体   繁体   English

使用命令行导入mysql数据库

[英]Importing a mysql database with command line

Have tried all other answers on stackoverflow, and they haven't worked. 在stackoverflow上尝试了所有其他答案,但没有成功。 I have a database in phpMyAdmin, and I need to update it. 我在phpMyAdmin中有一个数据库,我需要更新它。 The file is too big to upload via phpMyAdmin, and I've tried increasing limits in php.ini to no avail. 该文件太大,无法通过phpMyAdmin上载,因此我尝试增加php.ini中的限制无济于事。 I think that didn't work because I updated php.ini in public_html, and phpMyAdmin gets it memory/upload limits from the global file. 我认为这没有用,因为我在public_html中更新了php.ini,而phpMyAdmin从全局文件中获取了它的内存/上传限制。

Anyhow, people recommend command line, so this is what I tried: 无论如何,人们推荐命令行,所以这是我尝试过的:

# mysql -u db_username -p db_pw -h localhost  existing_empty_db_name < new_db.sql 

Then it just gives me a huge list of mysql options, and does nothing else. 然后,它只给了我大量的mysql选项,而没有执行任何其他操作。 I refresh the db in phpMyAdmin, and nothing has changed. 我在phpMyAdmin中刷新了数据库,但没有任何改变。 What am I missing? 我想念什么?

You are missing the -D option here. 您在这里缺少-D选项。 Correct syntax would be: 正确的语法为:

mysql -u db_username -p db_pw -h localhost -D existing_empty_db_name < new_db.sql 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM