forked from docs/doc-exports
Reviewed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com> Co-authored-by: Wang , Deng Ke <wangdengke2@huawei.com> Co-committed-by: Wang , Deng Ke <wangdengke2@huawei.com>
86 lines
22 KiB
HTML
86 lines
22 KiB
HTML
<a name="rds_migration_mysql"></a><a name="rds_migration_mysql"></a>
|
|
|
|
<h1 class="topictitle1">Migrating Data to RDS for MySQL Using mysqldump</h1>
|
|
<div id="body1523157571017"><div class="section" id="rds_migration_mysql__section8743122116813"><h4 class="sectiontitle">Preparing for Data Migration</h4><p id="rds_migration_mysql__p18884729686">You can access <span id="rds_migration_mysql__text17163125818533">RDS</span> DB instances through an <span id="rds_migration_mysql__text1872661892510">EIP</span> or through an ECS.</p>
|
|
<ol id="rds_migration_mysql__ol139261637897"><li id="rds_migration_mysql__li139261837895">Prepare an <span id="rds_migration_mysql__text10926835132517">ECS</span> for accessing DB instances in the same VPC or prepare a device for accessing <span id="rds_migration_mysql__text146991910810">RDS</span> through an EIP.<ul id="rds_migration_mysql__en-us_topic_0171122382_u674d5d5f798e42318e22f1b6c1da004c"><li id="rds_migration_mysql__en-us_topic_0171122382_le76498bda63d4a85a9fec893dcf446e7">To connect to a DB instance through an <span id="rds_migration_mysql__text1025815536257">ECS</span>, you need to create an <span id="rds_migration_mysql__text547519082620">ECS</span> first.<p id="rds_migration_mysql__en-us_topic_0171122382_af85e630b68ed430f9c87f1da6eebf075">For details about how to create and connect to an ECS, see <a href="rds_faq_0057.html">How Can I Create and Connect to an ECS?</a></p>
|
|
</li><li id="rds_migration_mysql__en-us_topic_0171122382_ldd1da393e9a045899ece19a659bc8f17">To connect to a DB instance through an EIP, you must:<ol type="a" id="rds_migration_mysql__en-us_topic_0171122382_oeb5130b0f58e40e6a1f4c00aef40d484"><li id="rds_migration_mysql__en-us_topic_0171122382_lb14b274cbccd4e7e82662778edffcf3d">Bind an EIP to a DB instance. For details, see <a href="rds_public_accessibility.html#rds_public_accessibility__section3199593620428">Binding an EIP</a>.</li><li id="rds_migration_mysql__en-us_topic_0171122382_ld70567b63d964e809cd3d3f673625ed3">Ensure that the local device can access the EIP.</li></ol>
|
|
</li></ul>
|
|
</li><li id="rds_migration_mysql__li9972439298">Install the MySQL client on the prepared <span id="rds_migration_mysql__text952978142615">ECS</span> or device.<p id="rds_migration_mysql__en-us_topic_0171122382_a5cacd7435b6b4f87a450e0df016822b0">For details, see <a href="rds_faq_0027.html">How Can I Install the MySQL Client?</a></p>
|
|
<div class="note" id="rds_migration_mysql__en-us_topic_0171122382_n57243281e6f94bd4ab3923ba046f6634"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="rds_migration_mysql__en-us_topic_0171122382_en-us_topic_0086557045_p591496422051">The MySQL client version must be the same as the version of RDS for MySQL. The MySQL database or client will provide mysqldump and mysql.</p>
|
|
<p id="rds_migration_mysql__p10819371924">After data is migrated to RDS, you may need to change the IP address. For details, see <a href="rds_05_0024.html">Configuring and Changing a Floating IP Address</a>.</p>
|
|
</div></div>
|
|
</li></ol>
|
|
</div>
|
|
<div class="section" id="rds_migration_mysql__section692873015104"><h4 class="sectiontitle">Exporting Data</h4><p id="rds_migration_mysql__p1896125315109">Before migrating data to <span id="rds_migration_mysql__text532013119101">RDS</span>, you need to export data first.</p>
|
|
<div class="notice" id="rds_migration_mysql__note84811310101214"><span class="noticetitle"><img src="public_sys-resources/notice_3.0-en-us.png"> </span><div class="noticebody"><ul id="rds_migration_mysql__en-us_topic_0171122585_ud06590f097cd495e84bddf04d72b0acf"><li id="rds_migration_mysql__en-us_topic_0171122585_en-us_topic_0086556980_li22821125629">The export tool must match the DB engine version.</li><li id="rds_migration_mysql__en-us_topic_0171122585_l0df8b85aa9634126b962b1413861a5d6">Database migration is performed offline. Before the migration, you must stop any applications using the source database.</li></ul>
|
|
</div></div>
|
|
<ol id="rds_migration_mysql__ol12419102361310"><li id="rds_migration_mysql__li241942320138"><span>Log in to the <span id="rds_migration_mysql__text14469162220269">ECS</span> or the device that can access <span id="rds_migration_mysql__text539014259227">RDS</span>.</span></li><li id="rds_migration_mysql__li16251172911136"><a name="rds_migration_mysql__li16251172911136"></a><a name="li16251172911136"></a><span>Use the mysqldump tool to export metadata into an SQL file.</span><p><div class="notice" id="rds_migration_mysql__en-us_topic_0171122585_n99ee9b6da8b0459c9e626a304e644853"><span class="noticetitle"><img src="public_sys-resources/notice_3.0-en-us.png"> </span><div class="noticebody"><p id="rds_migration_mysql__en-us_topic_0171122585_en-us_topic_0086556980_p218172199492">The MySQL database is required for <span id="rds_migration_mysql__text4653518101015">RDS</span> management. When exporting metadata, do not specify <strong id="rds_migration_mysql__a46bb9c76a5154e7599350579101e5549">--all-database</strong>. Otherwise, the MySQL database will be unavailable.</p>
|
|
</div></div>
|
|
<p id="rds_migration_mysql__en-us_topic_0171122585_a81841e148b264b388939b300f9f8b91c"><strong id="rds_migration_mysql__en-us_topic_0171122585_a1852de967c9b4e1b8883c6aecb2842cd">mysqldump</strong> <strong id="rds_migration_mysql__en-us_topic_0171122585_afd5b6747323149bd93fad2b359ae716e">--databases</strong> <<em id="rds_migration_mysql__en-us_topic_0171122585_a645e03a9cb4f4da09e7ecfd21a5cf50d">DB_NAME</em>> <strong id="rds_migration_mysql__en-us_topic_0171122585_a3fd0380796cb46058ecc8bef7da1809c">--single-transaction --order-by-primary --hex-blob --no-data --routines --events --set-gtid-purged=OFF</strong> -u <<em id="rds_migration_mysql__en-us_topic_0171122585_ad55feabf28714456bb6386dbb15a6312">DB_USER</em>> <strong id="rds_migration_mysql__en-us_topic_0171122585_en-us_topic_0086556980_b27760351740">-p -h</strong> <<em id="rds_migration_mysql__en-us_topic_0171122585_a4d16619a0ed3416ea075edc3abca0b2a">DB_ADDRESS</em>> <strong id="rds_migration_mysql__en-us_topic_0171122585_en-us_topic_0086556980_b455194631743">-P </strong><<em id="rds_migration_mysql__en-us_topic_0171122585_acc155dba5bbe4401aa2c8114dbbb714e">DB_PORT</em>> <strong id="rds_migration_mysql__en-us_topic_0171122585_en-us_topic_0086556980_b655995417458">|sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' -e 's/DEFINER[ ]*=.*FUNCTION/FUNCTION/' -e 's/DEFINER[ ]*=.*PROCEDURE/PROCEDURE/' -e 's/DEFINER[ ]*=.*TRIGGER/TRIGGER/' -e 's/DEFINER[ ]*=.*EVENT/EVENT/' ></strong> <em id="rds_migration_mysql__en-us_topic_0171122585_ae1f215ce5cee4a709014d95e717e88b2"><BACKUP_FILE></em></p>
|
|
<ul id="rds_migration_mysql__en-us_topic_0171122585_u3edc5a2dd5f540b29a57a3b21ceb7238"><li id="rds_migration_mysql__en-us_topic_0171122585_l72dd1104f9824387bdea698e65eade57"><em id="rds_migration_mysql__i842352697131411">DB_NAME</em> indicates the name of the database to be migrated.</li><li id="rds_migration_mysql__en-us_topic_0171122585_l68bb1085fd4945368fc5e8cbe23209da"><em id="rds_migration_mysql__i842352697131416">DB_USER</em> indicates the database username.</li><li id="rds_migration_mysql__en-us_topic_0171122585_lb54c4b11af7041e8a8e690a0d3cefc05"><em id="rds_migration_mysql__i842352697131420">DB_ADDRESS</em> indicates the database address.</li><li id="rds_migration_mysql__en-us_topic_0171122585_lf117ef26a7a346a59eb753b120e7e8e0"><em id="rds_migration_mysql__i842352697131425">DB_PORT</em> indicates the database port.</li><li id="rds_migration_mysql__en-us_topic_0171122585_ldb260531c8eb45a4b7c5b8d60d46efa5"><em id="rds_migration_mysql__i870398549172237">BACKUP_FILE</em> indicates the name of the file to which the data will be exported.</li></ul>
|
|
<p id="rds_migration_mysql__en-us_topic_0171122585_a8103de19ddc84969a24ce19a60a49a95">Enter the database password when prompted.</p>
|
|
<p id="rds_migration_mysql__en-us_topic_0171122585_a1f271d93ae7f437e94d4733c90c289fc">Example:</p>
|
|
<p id="rds_migration_mysql__en-us_topic_0171122585_a0bce502e26d94dcda286fa81223fe7a9"><strong id="rds_migration_mysql__en-us_topic_0171122585_a93c667b453e74d4f83d2959cefbbf58a">mysqldump --databases rdsdb --single-transaction --order-by-primary --hex-blob --no-data --routines --events --set-gtid-purged=OFF -u root -p -h 192.168.151.18 -P 3306 |sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' -e 's/DEFINER[ ]*=.*FUNCTION/FUNCTION/' -e 's/DEFINER[ ]*=.*PROCEDURE/PROCEDURE/' -e 's/DEFINER[ ]*=.*TRIGGER/TRIGGER/' -e 's/DEFINER[ ]*=.*EVENT/EVENT/' > dump-defs.sql</strong></p>
|
|
<p id="rds_migration_mysql__en-us_topic_0171122585_aae5d80e7dddc4c9a84e67a5f44def979"><strong id="rds_migration_mysql__en-us_topic_0171122585_ad8e63887da524df3933c6b37df7efe52">Enter password:</strong></p>
|
|
<div class="note" id="rds_migration_mysql__en-us_topic_0171122585_nbed2af7dc666459abca81d229e1b3feb"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="rds_migration_mysql__en-us_topic_0171122585_a8a6212c9f41b43f6a157c3734c506157">If you use mysqldump with a version earlier than 5.6, remove <strong id="rds_migration_mysql__a11c69fb37b8f44e0907c10bf5bf3453f">--set-gtid-purged=OFF</strong> before running this command.</p>
|
|
</div></div>
|
|
<p id="rds_migration_mysql__en-us_topic_0171122585_aa977313388774bdf8942be66965764f4">After this command is executed, a <strong id="rds_migration_mysql__adcaafa4a1955493bb4ddbdfebef0186f">dump-defs.sql</strong> file will be generated as follows:</p>
|
|
<pre class="screen" id="rds_migration_mysql__en-us_topic_0171122585_sa7a255cf104346ba83253e7ae22b6be5">[rds@localhost ~]$ ll dump-defs.sql
|
|
-rw-r-----. 1 rds rds 2714 Sep 21 08:23 dump-defs.sql</pre>
|
|
</p></li><li id="rds_migration_mysql__li04590327138"><span>Use the mysqldump tool to export data into an SQL file.</span><p><div class="notice" id="rds_migration_mysql__en-us_topic_0171122585_n7709487a692b45f88cacf26b6bc20391"><span class="noticetitle"><img src="public_sys-resources/notice_3.0-en-us.png"> </span><div class="noticebody"><p id="rds_migration_mysql__en-us_topic_0171122585_ab4c82130eaba42c4b3f781f435231588">The MySQL database is required for <span id="rds_migration_mysql__text15451756174616">RDS</span> management. When exporting metadata, do not specify <strong id="rds_migration_mysql__b1150145616462">--all-database</strong>. Otherwise, the MySQL database will be unavailable.</p>
|
|
</div></div>
|
|
<p id="rds_migration_mysql__en-us_topic_0171122585_en-us_topic_0086556980_p279338510243"><strong id="rds_migration_mysql__en-us_topic_0171122585_en-us_topic_0086556980_b583095917333">mysqldump --databases</strong> <<em id="rds_migration_mysql__en-us_topic_0171122585_afa58fe6fe27047b99baf349bed22a4e6">DB_NAME</em>> <strong id="rds_migration_mysql__en-us_topic_0171122585_a97357e0ad1fe4e2eb727e61139572cd5">--single-transaction --hex-blob --set-gtid-purged=OFF --no-create-info --skip-triggers</strong> <strong id="rds_migration_mysql__en-us_topic_0171122585_a5ea837816d834782b7745cbf2066e973">-u</strong> <<em id="rds_migration_mysql__en-us_topic_0171122585_ab4541b8eb73a49978a5acf2fed213257">DB_USER</em>> <strong id="rds_migration_mysql__en-us_topic_0171122585_en-us_topic_0086556980_b946317516218">-p</strong> <strong id="rds_migration_mysql__en-us_topic_0171122585_a6b5269827ed34f87bde89b7d04e8b2fa">-h</strong> <<em id="rds_migration_mysql__en-us_topic_0171122585_a29747ec9933f4b0386fe76ee5aa55732">DB_ADDRESS</em>> <strong id="rds_migration_mysql__en-us_topic_0171122585_a7692de295f384022a0db4715f949e94b">-P</strong> <<em id="rds_migration_mysql__en-us_topic_0171122585_a9edd1101ea8c49249114246075bb7b83">DB_PORT</em>> <strong id="rds_migration_mysql__en-us_topic_0171122585_ab18aa61eed0246ed90961af4e9a46c18">-r</strong> <<em id="rds_migration_mysql__en-us_topic_0171122585_aa165c514c82a4d1f97b6721470b2b4c4">BACKUP_FILE</em>></p>
|
|
<p id="rds_migration_mysql__en-us_topic_0171122585_a45486b42f5634c40b00ababb75b9ab28">For details on the parameters in the preceding command, see <a href="#rds_migration_mysql__li16251172911136">2</a>.</p>
|
|
<p id="rds_migration_mysql__en-us_topic_0171122585_a5220a0c335aa4905a751b960032cfd55">Enter the database password when prompted.</p>
|
|
<p id="rds_migration_mysql__en-us_topic_0171122585_a0ed339d9c740476082be1d62ccfb9171">Example:</p>
|
|
<p id="rds_migration_mysql__en-us_topic_0171122585_af11253eefc3d461393216b59f22f5b40"><strong id="rds_migration_mysql__en-us_topic_0171122585_a2a5292086fa84033afb6f8d2e45142a0">mysqldump --databases rdsdb --single-transaction --hex-blob --set-gtid-purged=OFF --no-create-info --skip-triggers -u root -p -h 192.168.151.18 -P <strong id="rds_migration_mysql__en-us_topic_0171122585_a666dfb267bcf46f7ae4fb7671666d86e">8635</strong> -r dump-data.sql</strong></p>
|
|
<div class="note" id="rds_migration_mysql__en-us_topic_0171122585_n3341bbbb3aa240d29d1e259b3298d0be"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="rds_migration_mysql__en-us_topic_0171122585_ad363fad3da9d4574be3ddb5c2a04572a">If you use mysqldump with a version earlier than 5.6, remove <strong id="rds_migration_mysql__b184795113819">--set-gtid-purged=OFF</strong> before running this command.</p>
|
|
</div></div>
|
|
<p id="rds_migration_mysql__en-us_topic_0171122585_a5eb9eef196f54421bd4c4e0a71613843">After this command is executed, a <strong id="rds_migration_mysql__b698854683">dump-data.sql</strong> file will be generated as follows:</p>
|
|
<pre class="screen" id="rds_migration_mysql__en-us_topic_0171122585_s1aea20a030b649d6a6277b59d0b1ed73">[rds@localhost ~]$ ll dump-data.sql
|
|
-rw-r-----. 1 rds rds 2714 Sep 21 08:23 dump-data.sql</pre>
|
|
</p></li></ol>
|
|
</div>
|
|
<div class="section" id="rds_migration_mysql__section9816229161211"><h4 class="sectiontitle">Importing Data</h4><p id="rds_migration_mysql__p135103395128">You can connect your client to <span id="rds_migration_mysql__text16976104018109">RDS</span> and import exported SQL files into <span id="rds_migration_mysql__text855117473103">RDS</span>.</p>
|
|
<div class="notice" id="rds_migration_mysql__note1265312113134"><span class="noticetitle"><img src="public_sys-resources/notice_3.0-en-us.png"> </span><div class="noticebody"><p id="rds_migration_mysql__en-us_topic_0171122655_ab96518d795b9443084060810191ea76f">If the source database calls triggers, stored procedures, functions, or events, you must set <strong id="rds_migration_mysql__ac480f3a10c3a48d3a83c7e4d46b36efe">log_bin_trust_function_creators</strong> to <strong id="rds_migration_mysql__a6b7dee3e07104fd69bae646ca4a1bd03">ON</strong> on the destination database before importing data.</p>
|
|
</div></div>
|
|
<ol id="rds_migration_mysql__ol12647173310134"><li id="rds_migration_mysql__li163101853174415"><span>Log in to the <span id="rds_migration_mysql__text143102535442">ECS</span> or the device that can access <span id="rds_migration_mysql__text731175317447">RDS</span>.</span></li><li id="rds_migration_mysql__li16471033171310"><span>Import metadata into <span id="rds_migration_mysql__text14263179101117">RDS</span>.</span><p><p id="rds_migration_mysql__en-us_topic_0171122655_ad627189ac9de4b1f9cf76d7f61442371"># <strong id="rds_migration_mysql__en-us_topic_0171122655_aaef0ea10e9884c1cbdf69ea37c256c35">mysql -f -h</strong> <em id="rds_migration_mysql__en-us_topic_0171122655_af2ac1a402e104ddf9438c93dd7ebf520"><RDS_ADDRESS></em> <strong id="rds_migration_mysql__en-us_topic_0171122655_acdb29a0d66814e288f8898efa5a2ec7b">-P</strong> <<em id="rds_migration_mysql__en-us_topic_0171122655_a92967b9900e24636b39c22df67922f01">DB_PORT</em>> <strong id="rds_migration_mysql__en-us_topic_0171122655_a2f7e70c7374341e4802fc77558a2ff92">-u</strong> root <strong id="rds_migration_mysql__en-us_topic_0171122655_a8d5442490a4c4c7eb865c2300069a702">-p < </strong><em id="rds_migration_mysql__en-us_topic_0171122655_a0d14ccb8d7894d05acdd2d672991c00d"><BACKUP_DIR></em><strong id="rds_migration_mysql__en-us_topic_0171122655_en-us_topic_0086557182_b410866411769">/dump-defs.sql</strong></p>
|
|
<ul id="rds_migration_mysql__en-us_topic_0171122655_ue08dae7d440142d6b806e475314cc15c"><li id="rds_migration_mysql__en-us_topic_0171122655_l66d52fdb329249bd98b6dba38cd31015"><em id="rds_migration_mysql__i186681139124711">RDS_ADDRESS</em>: indicates the IP address of the <span id="rds_migration_mysql__text1254610201115">RDS</span> DB instance.</li><li id="rds_migration_mysql__en-us_topic_0171122655_l2a7235d585234370bb8d176f2fa8d25e"><em id="rds_migration_mysql__i842352697131450">DB_PORT</em> indicates the RDS DB instance port.</li><li id="rds_migration_mysql__en-us_topic_0171122655_la4c2a7b031e14f5198911fcfc6128cf5"><em id="rds_migration_mysql__i1318558869164317">BACKUP_DIR</em> indicates the directory where <strong id="rds_migration_mysql__b1843852222164317">dump-defs.sql</strong> is stored.</li></ul>
|
|
<p id="rds_migration_mysql__en-us_topic_0171122655_a33e4fc3726f24842a47ded1fa4fb28d0">Example:</p>
|
|
<p id="rds_migration_mysql__en-us_topic_0171122655_a73ea44ae2cce4e62bcc6ebe1d5615b48"><strong id="rds_migration_mysql__en-us_topic_0171122655_a666dfb267bcf46f7ae4fb7671666d86e"># mysql -f -h 172.16.66.198 -P 3306 -u root -p < dump-defs.sql</strong></p>
|
|
<p id="rds_migration_mysql__en-us_topic_0171122655_a650167c458ca4d079039b4b8cff33c5f"><strong id="rds_migration_mysql__en-us_topic_0171122655_ab9808747fa0f4093bc11730a1e3f87c8">Enter password:</strong></p>
|
|
<div class="note" id="rds_migration_mysql__note187781520192"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="rds_migration_mysql__p13778520794">If you intend to import SQL statements of a table to RDS, you are advised to specify a database. Otherwise, the error message "No database selected" may be displayed. For example, if you intend to import SQL statements of a table to database <strong id="rds_migration_mysql__b6583747105013">mydb</strong>, run the following command:</p>
|
|
<p id="rds_migration_mysql__p203674533716"><strong id="rds_migration_mysql__b1136715553712"># mysql -f -h 172.16.66.198 -P 3306 -u root -p mydb < dump-defs.sql</strong></p>
|
|
<p id="rds_migration_mysql__p1136705143717"><strong id="rds_migration_mysql__b1036765193716">Enter password:</strong></p>
|
|
</div></div>
|
|
</p></li><li id="rds_migration_mysql__li144203861319"><span>Import data into <span id="rds_migration_mysql__text5315132617114">RDS</span>.</span><p><p id="rds_migration_mysql__en-us_topic_0171122655_afbf28e03c530431ca78bb14002b9332a"># <strong id="rds_migration_mysql__en-us_topic_0171122655_ab40a6bdd4696411588ed76521ab779d7">mysql -f -h</strong> <em id="rds_migration_mysql__en-us_topic_0171122655_abffbb448974d4e97a7ec840d13bd112c"><RDS_ADDRESS></em> <strong id="rds_migration_mysql__en-us_topic_0171122655_a3b4c10da33c943568a651611a0ce9468">-P</strong> <<em id="rds_migration_mysql__en-us_topic_0171122655_ad870a388d3a9439e82f1d4d96075d74c">DB_PORT</em>> <strong id="rds_migration_mysql__en-us_topic_0171122655_a3ad74e371ed348ef94d0fa2a1a10390d">-u</strong> root <strong id="rds_migration_mysql__en-us_topic_0171122655_afb14793e5010483eaa082305ff872db7">-p</strong> <strong id="rds_migration_mysql__en-us_topic_0171122655_a3ff674112cd545a79e20cf9b79f6889c">< </strong><em id="rds_migration_mysql__en-us_topic_0171122655_a69b432ca852a4af49d63c6b8905be84a"><BACKUP_DIR></em><strong id="rds_migration_mysql__en-us_topic_0171122655_a257d248c14444531901dd9c64f3f7e1f">/dump-data.sql</strong></p>
|
|
<ul id="rds_migration_mysql__en-us_topic_0171122655_u0ac3643f2b374fa08fbaa384f590b756"><li id="rds_migration_mysql__en-us_topic_0171122655_l709c62d4d1a3465aa2efd05a9b97dcc0"><em id="rds_migration_mysql__i111651516144812">RDS_ADDRESS</em>: indicates the IP address of the <span id="rds_migration_mysql__text816591613488">RDS</span> DB instance.</li><li id="rds_migration_mysql__en-us_topic_0171122655_l3c9115d96a56465ea6c93b51cce95679"><em id="rds_migration_mysql__i1334498693">DB_PORT</em> indicates the RDS DB instance port.</li><li id="rds_migration_mysql__en-us_topic_0171122655_lf42f6cb997714e8eabc8fe4c8627b306"><em id="rds_migration_mysql__i358084087164647">BACKUP_DIR</em> indicates the directory where <strong id="rds_migration_mysql__b1545433985164647">dump-data.sql</strong> is stored.</li></ul>
|
|
<p id="rds_migration_mysql__en-us_topic_0171122655_aa6a1b13a78964651b549690fc18280cc">Example:</p>
|
|
<p id="rds_migration_mysql__en-us_topic_0171122655_aacfbfa10a7b846998c94e6a8bb66fa34"><strong id="rds_migration_mysql__en-us_topic_0171122655_a850446a1e0e746f689e694e3eb3ea135"># mysql -f -h 172.16.66.198 -P 3306 -u root -p < dump-data.sql</strong></p>
|
|
<p id="rds_migration_mysql__en-us_topic_0171122655_a1a0cce98e4a74e9bb7802a44b572d452"><strong id="rds_migration_mysql__en-us_topic_0171122655_aca9ac01a6761483ba61f84291b7b93dd">Enter password:</strong></p>
|
|
<div class="note" id="rds_migration_mysql__note114821714171813"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="rds_migration_mysql__p134821314191815">If you intend to import SQL statements of a table to RDS, you are advised to specify a database. Otherwise, the error message "No database selected" may be displayed. For example, if you intend to import SQL statements of a table to database <strong id="rds_migration_mysql__b1981209153913">mydb</strong>, run the following command:</p>
|
|
<p id="rds_migration_mysql__p34821914181818"><strong id="rds_migration_mysql__b948219142189"># mysql -f -h 172.16.66.198 -P 3306 -u root -p mydb < dump-defs.sql</strong></p>
|
|
<p id="rds_migration_mysql__p1648213147185"><strong id="rds_migration_mysql__b048271412185">Enter password:</strong></p>
|
|
</div></div>
|
|
</p></li><li id="rds_migration_mysql__li89961538201313"><span>View the import result.</span><p><p id="rds_migration_mysql__en-us_topic_0171122655_a297f348fe3cb491f907871118e2db565"><strong id="rds_migration_mysql__en-us_topic_0171122655_a4fb5040044784406bf37d7c06d5e2c6d">mysql> show databases;</strong></p>
|
|
<p id="rds_migration_mysql__en-us_topic_0171122655_a70bdc92d0a6e4f97bf520b8834008732">The following result indicates that database <strong id="rds_migration_mysql__en-us_topic_0084612849_b842352706152359">rdsdb</strong> has been imported.</p>
|
|
<pre class="screen" id="rds_migration_mysql__en-us_topic_0171122655_s487e87b3cd6b458d91e877e9416617ba">mysql> show databases;
|
|
+--------------------+
|
|
| Database |
|
|
+--------------------+
|
|
| information_schema |
|
|
| rdsdb |
|
|
| mysql |
|
|
| performance_schema |
|
|
+--------------------+
|
|
4 rows in set (0.00 sec)</pre>
|
|
</p></li></ol>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="rds_05_0001_02.html">Data Migration</a></div>
|
|
</div>
|
|
</div>
|
|
|