简体   繁体   English

如何将数据库转储到远程服务器?

[英]How to dump database to a remote server?

I'm trying to push my database to a remote mysql database hosted on ClearDB. 我试图将数据库推送到ClearDB上托管的远程mysql数据库。

I'm using the command 我正在使用命令

 mysql -u username@us-cdbr-east-*** -pmypwd dbname < mydb.sql

I'm getting the error 我遇到了错误

 Access denied for user 'bbea98e4ba67c1@us-cdbr-east-**@localhost (using password YES)

Am i using the correct syntax ? 我使用的语法正确吗? I tried importing the same sql file to a local database and it happened smoothly. 我尝试将相同的sql文件导入本地数据库,但操作很顺利。

DO i need to GRANT some proviledges to this remote database on heroku ? 我是否需要在heroku上授予该远程数据库一些特权? If yes then how should i do it ? 如果是,那我该怎么办?

you should have privileges set on the database to be accessed from the remote host where you are trying to read in the dump. 您应该在数据库上设置特权,以便从尝试在转储中读取的远程主机进行访问。 When creating access for a username you always specify a corresponding host. 为用户名创建访问权限时,您始终指定一个相应的主机。 This could be % for any host... In that case you don't have to do anything. 对于任何主机,这可能都是%。在这种情况下,您无需执行任何操作。 Sometimes it is set to a specific host, in which case you need to add a privilege for the same username but with a different host being the remote host. 有时将其设置为特定的主机,在这种情况下,您需要为相同的用户名添加特权,但将不同的主机作为远程主机。

Also you need the correct syntax would be: 另外,您需要正确的语法是:

 mysql -u username -h us-cdbr-east-*** -pmypwd dbname < mydb.sql

notice the -h switch 注意-h开关

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

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