{"id":1665,"date":"2009-12-22T13:35:57","date_gmt":"2009-12-22T13:35:57","guid":{"rendered":"https:\/\/www.diaryofanadi.co.uk\/?p=1665"},"modified":"2009-12-22T13:35:57","modified_gmt":"2009-12-22T13:35:57","slug":"importing-a-mysql-dump-to-a-new-database","status":"publish","type":"post","link":"https:\/\/diaryofanadi.co.uk\/?p=1665","title":{"rendered":"Importing A MySQL Dump To A New Database"},"content":{"rendered":"<p>My web host is <a title=\"1&amp;1 Internet Homepage\" href=\"http:\/\/order.1and1.co.uk\/xml\/order\/Home;jsessionid=3EB9B1CFADE16DB14EF3D72C8839A792.TCpfix151b?__reuse=1261472174800\" target=\"_blank\" rel=\"noopener\"> 1&amp;1<\/a> &#8211; I joined up with them a couple of years ago because they were doing a &#8216;free year&#8217; offer, and my then web host\u00a0(UKHosts)\u00a0had really annoyed me by being hacked (and whoever did it had deleted all the index files and main images)&#8230;  but not telling me until some of my clients complained their websites were down, and<strong> I<\/strong> called <strong>them<\/strong>! (And see the comment right at the end of this article &#8211; looks like it may have happened again.) <\/p>\n<p>The old &#8220;we tried to call you when it happened&#8221; crap didn&#8217;t cut any ice with me.<\/p>\n<p>Anyway, the great thing about  1&amp;1  is that if you email them with a technical query (or any other type of question come to that), they respond within an hour. UKHosts used to <strong>ignore<\/strong> their emails and it was always the same guy who eventually dealt with any query after you&#8217;d eventually lost your temper and sent an arsey email. Plus, their phone was permanently engaged or otherwise on answerphone &#8211; which they also never used to respond to.<\/p>\n<p>Anyway, I use WordPress to run this blog. Every so often there is an upgrade to fix bugs or add new features, and so far that hasn&#8217;t been an issue. However, with the last upgrade you can only run WordPress from a MySQL database version higher than 4.1.something (I forget which now). Mine was 4.0.something.<\/p>\n<p>My account allows me to create MySQL 4 and MySQL 5 databases, and in the recesses of my mind I seem to have a recollection that WordPress specifically mentioned MySQL 4 when I first set it up. Therefore, I was running WordPress from the earlier version of a\u00a0MySQL database.<\/p>\n<p>Creating a new MySQL 5 database was easy &#8211; but it was empty! I needed to be able to transfer my old database data into the new one. Everything indicated that this was a walk in the park. An absolute doddle. After all, I had made periodic backups of my database, so I could restore the site quickly if anything ever went wrong. Well, all I can say is, I am bloody happy that I never had to do that. I had plenty of fun and games doing what appears to be a simple operation.<\/p>\n<p>The only criticism I would have of 1&amp;1 over this was their FAQs. Basically, they are wrong (unless they have updated them as a result of my problem). At best, the FAQs are incredibly misleading &#8211; missing out spaces on instructions for command line operations is a guaranteed disaster &#8211; and command line systems are not known for being logical in the first place.<\/p>\n<p>Anyway, without going into huge detail over what went wrong, here is how to do it right (and it was 1&amp;1 who sorted this out for me). I will assume you have created a new MySQL 5 database from within your Admin Panel.<\/p>\n<p>First of all you need to back up your old database. Go to yourAdmin Panel, go to the MySQL Admin area,\u00a0and choose the database you want to back up:<\/p>\n<div id=\"attachment_2664\" style=\"width: 490px\" class=\"wp-caption alignleft\"><img decoding=\"async\" aria-describedby=\"caption-attachment-2664\" class=\"size-full wp-image-2664 lazyload\" title=\"Select Your Database\" data-src=\"https:\/\/www.diaryofanadi.co.uk\/wp-content\/uploads\/2009\/12\/sql_31.gif\" alt=\"Select Your Database\" width=\"480\" height=\"58\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 480px; --smush-placeholder-aspect-ratio: 480\/58;\" \/><p id=\"caption-attachment-2664\" class=\"wp-caption-text\">Select Your Database<\/p><\/div>\n<p>In the\u00a0PHPMyAdmin area, click on &#8220;Export&#8221;:<\/p>\n<div class=\"mceTemp mceIEcenter\" style=\"text-align: left;\">\n<div id=\"attachment_2665\" style=\"width: 489px\" class=\"wp-caption alignleft\"><img decoding=\"async\" aria-describedby=\"caption-attachment-2665\" class=\"size-full wp-image-2665 lazyload\" title=\"Export The Database\" data-src=\"https:\/\/www.diaryofanadi.co.uk\/wp-content\/uploads\/2009\/12\/sql_41.gif\" alt=\"Export The Database\" width=\"479\" height=\"362\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 479px; --smush-placeholder-aspect-ratio: 479\/362;\" \/><p id=\"caption-attachment-2665\" class=\"wp-caption-text\">Export The Database<\/p><\/div>\n<\/div>\n<p>In the database window (shown below), leave everything unchanged except for the tick box (circled) &#8211; you want to save your file &#8211; and make sure the SQL option is selected:<\/p>\n<div class=\"mceTemp mceIEcenter\" style=\"text-align: left;\">\n<div id=\"attachment_2666\" style=\"width: 490px\" class=\"wp-caption alignleft\"><img decoding=\"async\" aria-describedby=\"caption-attachment-2666\" class=\"size-full wp-image-2666 lazyload\" title=\"Select Settings And Save File\" data-src=\"https:\/\/www.diaryofanadi.co.uk\/wp-content\/uploads\/2009\/12\/sql_51.gif\" alt=\"Select Settings And Save File\" width=\"480\" height=\"519\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 480px; --smush-placeholder-aspect-ratio: 480\/519;\" \/><p id=\"caption-attachment-2666\" class=\"wp-caption-text\">Select Settings And Save File<\/p><\/div>\n<\/div>\n<p>Just choose somewhere to save the file where you can find it (call it something simple like &#8216;dump_db&#8217;), then click GO. This will create your backup file.<\/p>\n<p>Now you need to use your FTP client to upload the &#8216;dump_db.sql&#8217; file to the root directory of your webspace &#8211; that&#8217;s the highest level you can go to, above all your folders for your websites.<\/p>\n<p>All of this was the easy part. 1&amp;1 has various FAQs for importing the dumped database, but none of them worked for me. It turned out my database was too big (it was less than 7MB, but they&#8217;d told me it just needed to be less than 9MB for the standard import from MyPHPAdmin to work).<\/p>\n<p>If you are lucky, clicking on the SQL button will allow you to browse your PC for the dumped file and restore it from there. But I <strong>wasn&#8217;t<\/strong> lucky. I had to use SSH to complete the restore.<\/p>\n<p>I <a title=\"PuTTY Download Page\" href=\"http:\/\/www.chiark.greenend.org.uk\/~sgtatham\/putty\/download.html\" target=\"_blank\" rel=\"noopener\"> downloaded PuTTY<\/a> (an open source\u00a0telnet client). You just run this program from the downloaded file &#8211; it doesn&#8217;t install anything to your PC. When it opens, it looks like this:<\/p>\n<div id=\"attachment_1672\" style=\"width: 476px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.diaryofanadi.co.uk\/wp-content\/uploads\/2009\/12\/putty_1.gif\"><img decoding=\"async\" aria-describedby=\"caption-attachment-1672\" class=\"size-full wp-image-1672 lazyload\" title=\"PuTTY Settings Window\" data-src=\"https:\/\/www.diaryofanadi.co.uk\/wp-content\/uploads\/2009\/12\/putty_1.gif\" alt=\"PuTTY Settings Window\" width=\"466\" height=\"448\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 466px; --smush-placeholder-aspect-ratio: 466\/448;\" \/><\/a><p id=\"caption-attachment-1672\" class=\"wp-caption-text\">PuTTY Settings Window<\/p><\/div>\n<p>Type in your host name &#8211; it&#8217;s the name you use in your FTP client and will be something like &#8216;ftp.yourdomainname.co.uk&#8217;. Make sure SSH is selected, then click &#8216;Open&#8217;. You will now get the telnet window, like this:<\/p>\n<div class=\"mceTemp mceIEcenter\" style=\"text-align: left;\">\n<div id=\"attachment_2667\" style=\"width: 490px\" class=\"wp-caption alignleft\"><img decoding=\"async\" aria-describedby=\"caption-attachment-2667\" class=\"size-full wp-image-2667 lazyload\" title=\"PuTTY Telnet Window\" data-src=\"https:\/\/www.diaryofanadi.co.uk\/wp-content\/uploads\/2009\/12\/putty_21.gif\" alt=\"PuTTY Telnet Window\" width=\"480\" height=\"302\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 480px; --smush-placeholder-aspect-ratio: 480\/302;\" \/><p id=\"caption-attachment-2667\" class=\"wp-caption-text\">PuTTY Telnet Window<\/p><\/div>\n<\/div>\n<p>At the prompt, type in your username (again, the one you use to access your webspace using your FTP client &#8211; with 1&amp;1 it&#8217;ll be something like &#8216;u50012345&#8217;), then press ENTER. Enter your password (same as your FTP again), and press ENTER. You&#8217;ll now see something like this:<\/p>\n<div class=\"mceTemp mceIEcenter\" style=\"text-align: left;\">\n<div class=\"mceTemp\">\n<div id=\"attachment_2669\" style=\"width: 490px\" class=\"wp-caption alignleft\"><img decoding=\"async\" aria-describedby=\"caption-attachment-2669\" class=\"size-full wp-image-2669 lazyload\" title=\"Logged Into Your Server\" data-src=\"https:\/\/www.diaryofanadi.co.uk\/wp-content\/uploads\/2009\/12\/putty_32.gif\" alt=\"Logged Into Your Server\" width=\"480\" height=\"302\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 480px; --smush-placeholder-aspect-ratio: 480\/302;\" \/><p id=\"caption-attachment-2669\" class=\"wp-caption-text\">Logged Into Your Server<\/p><\/div>\n<\/div>\n<\/div>\n<p>Now you&#8217;re ready for the most important &#8211; and most tricky &#8211; part. You&#8217;ve got to run a command to copy the dumped database into the new one. It has to be typed EXACTLY right using the EXACT parameters (this was one of the confusing parts of the FAQs, because the usernames and passwords are not what you&#8217;d expect unless you&#8217;ve done this before).<\/p>\n<p>Look at your list of databases again (in your MySQL Admin area):<\/p>\n<div class=\"mceTemp mceIEcenter\" style=\"text-align: left;\">\n<div id=\"attachment_2670\" style=\"width: 490px\" class=\"wp-caption alignleft\"><img decoding=\"async\" aria-describedby=\"caption-attachment-2670\" class=\"size-full wp-image-2670 lazyload\" title=\"The Database List\" data-src=\"https:\/\/www.diaryofanadi.co.uk\/wp-content\/uploads\/2009\/12\/sql_61.gif\" alt=\"The Database List\" width=\"480\" height=\"58\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 480px; --smush-placeholder-aspect-ratio: 480\/58;\" \/><p id=\"caption-attachment-2670\" class=\"wp-caption-text\">The Database List<\/p><\/div>\n<\/div>\n<p>Those values I have highlighted are the database name, the database username, and the database host name. You&#8217;ll also need a password &#8211; and this is one which you set up specifically for SSH from your main Admin Panel. Note that the names are for the MySQL 5 database &#8211; the one you want to copy your dumped data into.<\/p>\n<p>At the prompt in the telnet (PuTTY)\u00a0window, you must type the following. It has to be exactly like this (substituting the relevant data from your Admin Panel):<\/p>\n<p style=\"text-align: left; font-family: courier;\"><span style=\"color: #008000;\">mysql -h db9876.oneandone.co.uk -u dbo343434343 -p db343434343 &lt; dump_file.sql <\/p>\n<p>Let me just repeat that, but highlighting the spaces you must type using the symbol &#8220;<span style=\"color: #ff0000;\">\u2022 &#8221; in red:<\/p>\n<p style=\"text-align: left; font-family: courier;\">mysql<span style=\"color: #ff0000;\">\u2022 -h<span style=\"color: #ff0000;\">\u2022 db9876.oneandone.co.uk<span style=\"color: #ff0000;\">\u2022 -u<span style=\"color: #ff0000;\">\u2022 dbo343434343<span style=\"color: #ff0000;\">\u2022 -p<span style=\"color: #ff0000;\">\u2022 db343434343<span style=\"color: #ff0000;\">\u2022 &lt;<span style=\"color: #ff0000;\">\u2022 dump_file.sql<\/p>\n<p>Press ENTER, then type in your SSH password when prompted, and press ENTER again. The command will execute and your new MySQL 5 database should now contain all your dumped data.<\/p>\n<p> <strong>EDIT 03\/01\/2010:<\/strong> I noticed someone searching for &#8220;how to open an sql file and edit&#8221;. This is quite simple &#8211; you need to use a text editor that doesn&#8217;t alter the file by adding headers or messing with file extensions.  <a title=\"Notepad++ Download Site\" href=\"http:\/\/notepad-plus.sourceforge.net\/uk\/site.htm\" target=\"_blank\" rel=\"noopener\"> Notepad++ is an open source program<\/a>  and works perfectly for this and other code editing. <\/p>\n<p> <strong>EDIT 22\/1\/2010:<\/strong> In the last two days I have had several hits on the search term &#8220;ukhosts hacked&#8221;. My experience was well over a year ago (I&#8217;ve been with 1&amp;1 for over a year, and I changed to them directly as a result of the example I gave at the start of this article). I can only guess that UKHosts has been hacked again. <\/p>\n<p> If anyone knows, use the Contact Form from the menu above and give me the details. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>My web host is 1&amp;1 &#8211; I joined up with them a couple of years ago because they were doing a &#8216;free year&#8217; offer, and my then web host\u00a0(UKHosts)\u00a0had really annoyed me by being hacked (and whoever did it had deleted all the index files and main images)&#8230; but not telling me until some of [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[121],"tags":[],"class_list":["post-1665","post","type-post","status-publish","format-standard","hentry","category-latestposts"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/diaryofanadi.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1665","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/diaryofanadi.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/diaryofanadi.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/diaryofanadi.co.uk\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/diaryofanadi.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1665"}],"version-history":[{"count":0,"href":"https:\/\/diaryofanadi.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1665\/revisions"}],"wp:attachment":[{"href":"https:\/\/diaryofanadi.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1665"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/diaryofanadi.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1665"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/diaryofanadi.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1665"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}