我如何导入本地的MySQL数据库,以RDS数据库实例? [英] How do I import a local MySQL db to RDS db instance?

查看:444
本文介绍了我如何导入本地的MySQL数据库,以RDS数据库实例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个RDS实例调用realcardiodb(发动机的mysql) 我已经从我的本地出口我的数据库。文件被保存在当地称为localhostrealcardio.sql

I've created a RDS instance called realcardiodb (the engine is mysql) and I've exported my database from my localhost. File is saved locally called localhostrealcardio.sql

大多数的研究说,使用mysqldump的从本地系统中导入数据到Web服务器上,但我的系统竟然不认mysqldump的。

Most research says to use mysqldump to import data from a local system to a web server, but my system doesn't even recognize mysqldump.

C:\xampp\mysql>mysqldump
'mysqldump' is not recognized as an internal or external command, operable program or batch   file. 

我如何解决这个错误,我应该使用mysqldump? (我绝对有MySQL的安装在我的系统)

How do I resolve this error should I use mysqldump? (I definitely have mysql install on my system)

有没有更好的工具,我应该使用?

Is there a better utility I should use?

任何帮助是AP preciated,特别是如果你有经验导入MySQL来AWS RDS。

Any help is appreciated, especially if you have experience importing mysql to aws rds.

谢谢! DK

更新7/31/2012 所以,我得到了错误决定。 mysqldump的是bin目录C:\ XAMPP的\ mysql的\ BIN> mysqldump的 AWS提供了folloinwg说明上载本地数据库RDS:

Update 7/31/2012 So I got the error resolved. mysqldump is in the bin directory C:\xampp\mysql\bin>mysqldump AWS provides the folloinwg instructions for uploading a local database to RDS:

mysqldump acme | mysql --host=hostname --user=username --password acme

有人能打破这对我?

Can someone break this down for me?

1)是第一个'极致'(的mysqldump命令后)我的本地数据库的名称或我保存在本地导出的SQL文件?

1) Is the first 'acme' (after mysqldump command) the name of my local database or the exported sql file I saved locally?

2)是主机的IP地址,公用DNS,RDS端点或者两者都不是?

2)Is the hostname the IP address, Public DNS, RDS Endpoint or neither?

3)我假设用户名和密码是RDS凭据和第二极致是我在RDS创建的数据库的名称。

3)The username and password I assume is the RDS credentials and the second acme is the name of the database I created in RDS.

谢谢!

推荐答案

这是我做到了一对夫妇的实例是有MySQL的表中的数据。

的步骤来创建一个RDS数据库实例: <一href="http://docs.amazonwebservices.com/AmazonRDS/latest/GettingStartedGuide/C">http://docs.amazonwebservices.com/AmazonRDS/latest/GettingStartedGuide/C...

The steps to creating an RDS database instance: http://docs.amazonwebservices.com/AmazonRDS/latest/GettingStartedGuide/C...

注意:的确认RDS实例都有一个涉及EC2安全组配置了安全组。 <一href="http://docs.amazonwebservices.com/AmazonRDS/latest/UserGuide/USER_Workin">http://docs.amazonwebservices.com/AmazonRDS/latest/UserGuide/USER_Workin...

Note: Make sure the RDS instance has a security group configured that relates to the EC2 security group. http://docs.amazonwebservices.com/AmazonRDS/latest/UserGuide/USER_Workin...

在我们前进,让我提供什么样的一些以下占位符是一个列表:

Before we go forward, let me provide a list of what some of the following placeholders are:

  • host.address.for.rds.server =这将是怎样被称为在你的RDS说明/设置页面中的终点。
  • rdsusername =你RDS安装过程中创建的主用户帐户。
  • rdsdatabase =你在你的RDS实例的服务器中创建一个空数据库。
  • backupfile.sql =的SQL转储文件你使你的pre-现有安装的数据库。

一旦你创建了一个新的RDS数据库实例,并且配置安全设置,登录到该服务器(从SSH会话中,以您的EC2服务器),然后创建使用基本的SQL命令的实例中一个空数据库。

Once you've created a fresh RDS database instance, and have configured its security settings, log into this server (from within an ssh session to your EC2 server) and then create an empty database inside the instance using basic SQL commands.

mysql -h host.address.for.rds.server -P 3306 -u rdsusername -p
(enter your password)
create database rdsdatabase;

然后退出你的RDS服务器内部MySQL的环境。

Then quit out of the MySQL environment inside your RDS server.

\q

本教程假设你已经从你的旧数据库的备份。如果你不这样做,请立即创建一个。在这之后,你就可以导入SQL转储文件装入空数据库等待您的RDS服务器上。

This tutorial assumes you already have a backup from your old database. If you don't, go create one now. After that, you’re ready to import that sql dump file into the empty database waiting on your RDS server.

mysql -h host.address.for.rds.server -u rdsusername -p  rdsdatabase < backupfile.sql

这可能需要几秒钟才能完成,这取决于SQL转储文件的大小。你的迹象表明,它完成的是bash命令提示符重新出现。

It might take a few seconds to complete, depending on the size of the sql dump file. Your indication that it is finished is that the bash command prompt reappears.

请注意:命令的mysqlimport时使用直接导入数据到数据库中现有的表。这似乎是我们在进口的数据,但这不是我们实际上做在这种情况下。我们正在迁移到该数据库还没有任何表,和我们使用SQL转储文件包含SQL命令生成需要。

Note: the command "mysqlimport" is used when imported data directly into an existing table inside a database. It might seem like we’re "importing" data, but this is not what we’re actually doing in this situation. The database we are migrating to has no tables yet, and the sql dump file we’re using contains the sql commands to generate the tables it needs.

确认传输

现在,如果你没有得到任何的错误信息,那么你的SQL可能转移工作。如果你愿意,你可以仔细检查,看它是否确实通过连接到您的RDS数据库服务器,查找您创建的数据库,并检查是否表,现在present。

Now, if you didn't get any error messages, then your sql transfer probably worked. If you want, you can double check to see if it did by connecting to your RDS database server, looking up the database you created, and check to see if the tables are now present.

mysql -h host.address.for.rds.server -P 3306 -u rdsusername -p
(enter your password)
use rdsdatabase;
show tables;

这篇关于我如何导入本地的MySQL数据库,以RDS数据库实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆