简体   繁体   English

如何将我的 mysql 数据库从 phpmyadmin 推送到 heroku 的 cleardb?

[英]How do I push my mysql database from phpmyadmin to heroku's cleardb?

I'm using WAMP server for running my php app.我正在使用 WAMP 服务器来运行我的 php 应用程序。 I have a database BOOK in phpmyadmin.我在 phpmyadmin 中有一个数据库 BOOK。 How can I push this data to heroku.如何将此数据推送到heroku。 I have used add on to add cleardb to my app.我已经使用 add on 将 cleardb 添加到我的应用程序中。

heroku config shows the database url too. heroku 配置也显示了数据库 url。

I tried我试过

db:push mysql://root@localhost/BOOK 

but it didn't work.但它没有用。

ERROR -->错误-->

 Failed to connect to database:
 Sequel::AdapterNotFound -> LoadError: cannot load such file -- mysql

ClearDB recommends using mysql and mysqldump for importing data. ClearDB 推荐使用mysqlmysqldump来导入数据。 From Frequently Asked Questions on ClearDB.com:来自 ClearDB.com 上的常见问题解答

For importing data into your MySQL database, we recommend that you use both the mysql command line client as well as the mysqldump database backup utility.

Syntax for importing is something like this:导入的语法是这样的:

$ mysql <dbname> -u <username> -p<password> < <file.sql>

If you don't have mysql installed locally, type "mysql" into terminal will inevitably result in "command not found".如果本地没有安装mysql,在终端中输入“mysql”难免会出现“command not found”。 MAMP provides command line syntax to resolve this problem. MAMP 提供了命令行语法来解决这个问题。 Thus, if we don't want to change $PATH to use 'mysql' command directly (there is really no need, in my opinion, if all we are going to use command line mysql for is database migration), we can run the following import syntax:因此,如果我们不想将 $PATH 更改为直接使用 'mysql' 命令(在我看来,真的没有必要,如果我们将使用命令行 mysql 进行数据库迁移),我们可以运行以下导入语法:

$/Applications/MAMP/Library/bin/mysql --host=localhost -uroot -proot -u username -h hostname -p < exported_sql_file.sql

The CLI shall prompt for password input. CLI 将提示输入密码。 And then the database in exported_sql_file.sql will be imported to clearDB.然后exported_sql_file.sql中的数据库将被导入到clearDB中。 For how to acquire 'username', 'hostname', and 'password' for the import syntax, refer to this tutorial for help .有关如何获取导入语法的“用户名”、“主机名”和“密码”,请参阅本教程以获取帮助

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

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