{"id":873,"date":"2010-05-04T16:54:19","date_gmt":"2010-05-04T16:54:19","guid":{"rendered":"http:\/\/kedar.nitty-witty.com\/?p=873"},"modified":"2018-02-14T14:30:26","modified_gmt":"2018-02-14T14:30:26","slug":"steps-to-move-copy-rename-mysql-database","status":"publish","type":"post","link":"https:\/\/kedar.nitty-witty.com\/blog\/steps-to-move-copy-rename-mysql-database","title":{"rendered":"Steps to Move Copy Rename MySQL Database"},"content":{"rendered":"<p>Moving, copying or renaming database is a very basic activity. I have just noted a few commands for reference to quickly follow the required operation.<\/p>\n<p><strong>1. Rename database on Linux Machine:<br \/>\n<\/strong><br \/>\nA. Use RENAME DATABASE Command [MySQL 5.1].<\/p>\n<blockquote><p>RENAME DATABASE db_name TO new_db_name;<\/p><\/blockquote>\n<p>B.<\/p>\n<blockquote><p>mysql -uroot -pPASSWORD -e &#8220;drop database if exists NEW-DB-NAME; create database NEW-DB-NAME&#8221; &amp;&amp; mysqldump -uroot -pPASSWORD SOURCE-DB-NAME | mysql -uroot -pPASSWORD NEW-DB-NAME &amp;&amp; mysql -uroot -pPASSWORD -e &#8220;drop database SOURCE-DB-NAME&#8221;<\/p><\/blockquote>\n<p><strong>2. Create Duplicate of a database:<br \/>\n<\/strong><\/p>\n<blockquote><p>mysql -uroot -ppassword -e &#8220;drop database if exists DB_TO_BE_CREATED;create database DB_TO_BE_CREATED;&#8221; | mysqldump -uroot -ppassword DB_TO_BE_COPIED | mysql -uroot -ppassword DB_TO_BE_CREATED<\/p><\/blockquote>\n<p style=\"text-align: left;\"><strong>3. Copy MySQL Database to Remote MySQL Server:<\/strong><\/p>\n<p style=\"text-align: right;\">\n<p>3A. By using -h (hostname) option.<\/p>\n<p>Create MySQL Dump:<\/p>\n<blockquote><p>mysqldump -uroot -ppassword &#8211;databases DB_TO_BE_COPIED &gt; DB_TO_BE_COPIED.sql<\/p><\/blockquote>\n<p>Load MySQL Dump:<\/p>\n<blockquote><p>mysql -uroot -ppassword -hHOSTNAME &lt; DB_TO_BE_COPIED.sql OR Using Single Command: mysql -uroot -ppassword -e &#8220;drop database if exists DB_TO_BE_CREATED;create database DB_TO_BE_CREATED;&#8221; | mysqldump -uroot -ppassword DB_TO_BE_COPIED | mysql -uroot -ppassword -hHOSTNAME DB_TO_BE_CREATED 3B. By moving dump file to remote server. Create MySQL Dump: mysqldump -uroot -ppassword &#8211;databases DB_TO_BE_COPIED &gt; DB_TO_BE_COPIED.sql<\/p><\/blockquote>\n<p>Copy SQL file to remote MySQL Server:<\/p>\n<blockquote><p>scp DB_TO_BE_COPIED.sql username@remote-machin:\/path\/to\/copy<\/p><\/blockquote>\n<p>Login to remote-machin.<\/p>\n<p>Load MySQL Dump:<\/p>\n<blockquote><p>mysql -uroot -ppassword DB_TO_BE_CREATED &lt; \/path\/to\/copy\/DB_TO_BE_COPIED.sql<\/p><\/blockquote>\n<p>Here, I haven&#8217;t considered copying and moving data-files for MyISAM databases as these are just the commands-way.<\/p>\n","protected":false},"excerpt":{"rendered":"Moving, copying or renaming database is a very basic activity. I have just noted a few commands for reference to quickly follow the required operation. 1. Rename database on Linux&hellip;\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[8,377],"tags":[235,33,233,76,234],"class_list":{"0":"post-873","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-mysql","7":"category-mysql-articles","8":"tag-copy-mysql-databaes","9":"tag-database","10":"tag-move-mysql-database","11":"tag-mysqldump","12":"tag-rename-mysql-database"},"aioseo_notices":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/posts\/873","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/comments?post=873"}],"version-history":[{"count":2,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/posts\/873\/revisions"}],"predecessor-version":[{"id":2458,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/posts\/873\/revisions\/2458"}],"wp:attachment":[{"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/media?parent=873"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/categories?post=873"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kedar.nitty-witty.com\/blog\/wp-json\/wp\/v2\/tags?post=873"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}