{"id":724,"date":"2006-11-30T10:13:17","date_gmt":"2006-11-30T04:43:17","guid":{"rendered":"http:\/\/tao.kaoart.info\/blog-others\/kunstao\/2006\/724\/"},"modified":"2006-11-30T10:13:17","modified_gmt":"2006-11-30T04:43:17","slug":"%e5%a6%82%e4%bd%95%e7%94%a8%e5%91%bd%e4%bb%a4%e8%a1%8cssh%e5%a4%87%e4%bb%bd%e5%92%8c%e6%81%a2%e5%a4%8dmysql%e6%95%b0%e6%8d%ae%e5%ba%93","status":"publish","type":"post","link":"https:\/\/tao0.date\/?p=724","title":{"rendered":"\u5982\u4f55\u7528\u547d\u4ee4\u884cSSH\u5907\u4efd\u548c\u6062\u590dMYSQL\u6570\u636e\u5e93"},"content":{"rendered":"<p>This method works regardless of the size of your database.  You must have SSH access to your server.  On (gs) plans you can invoke SSH access from within your Control Panel. On (dv) plans you must enable Shell Access through Plesk.<br \/>\n\u8fd9\u4e2a\u65b9\u6cd5\u63a8\u8350\u7ed9\u5177\u6709\u5927\u6570\u636e\u5e93\u7684\u5bb6\u4f19\uff0c\u800c\u4e14\u4f60\u5fc5\u987b\u6709SSH\u6743\u9650\uff0c<br \/>\n\u5907\u4efdBACKUP:<br \/>\n<!--more--><br \/>\n1) Log into your server via SSH and cd into a directory where your user has write access.  On (ss) plans<br \/>\n   you would do something like this:<br \/>\n        cd \/var\/www\/html\/<br \/>\n2) Enter the following command:<br \/>\n        mysqldump \u2013add-drop-table -u Username -p dbname > dbname.sql<br \/>\n        &#8211; omit the \u2018\u2013add-drop-table\u2019 argument if you\u2019ll want to merge this backup with an existing database<br \/>\n          upon restoral<br \/>\n        &#8211; Where \u2018Username\u2019 is replaced by the mySQL username.  On (ss) plans this user is the same as the<br \/>\n          administrative FTP user.  On (as) plans this user can be found by logging into Plesk, clicking<br \/>\n          on the domain and going to databases and clicking on the database to be backed up.<br \/>\n        &#8211; Replace \u2018dbname\u2019 with the name of the database to be backed up.<br \/>\n        &#8211; Replace dbname.sql with what you\u2019d like to name the backup.<br \/>\n3) Enter your mySQL password at the prompt.  If you don\u2019t know it you can reset it in your webcontrol or Plesk<br \/>\n   admin panel \u8981\u8f93\u5165\u6b63\u786e\u7684\u6570\u636e\u5e93\u5bc6\u7801\uff0c\u8981\u662f\u5fd8\u4e86\u5c31\u5728\u63a7\u5236\u9762\u677f\u91cc\u91cd\u8bbe\u3002<br \/>\n        &#8211; If you get an error that looks like this:<br \/>\n                ERROR 1045: Access denied for user: \u2018Username@localhost\u2019 (Using password: YES)<br \/>\n          you have entered an incorrect password, please retype it carefully or reset it to something else via<br \/>\n          the webcontrol panel or Plesk administrator<br \/>\n                &#8211; On (ss) plans if you have reset the password in the webcontrol panel and are sure you\u2019ve entered it correctly<br \/>\n                  on the command line this might be a permissions problem.  Try renaming your database to something else in the<br \/>\n                  webcontrol panel and then back to the original, this often fixes permissions problems.<br \/>\n4) Use FTP to download the file to your backup location, probably your local computer.<br \/>\n        &#8211; Don\u2019t forget to delete the backup from your public html directory after you\u2019ve found a safe place for it.<br \/>\n          You don\u2019t want to leave your backup lying around where anyone with a web browser can download a copy.<br \/>\n\u6062\u590dRESTORE:<br \/>\n1) Use FTP to upload the file to your server, your public html directory will work for now<br \/>\n        &#8211; Don\u2019t forget to delete the backup from your public html directory after you\u2019ve done the database restoral.<br \/>\n          You don\u2019t want to leave your backup lying around where anyone with a web browser can download a copy.<br \/>\n\u7528FTP\u5de5\u5177\u628a\u6570\u636e\u5e93\u6587\u4ef6\u4e0a\u4f20\u5230\u4f60\u7684public_html\u76ee\u5f55\uff0c\u522b\u5fd8\u4e86\u5220\u9664\u8fd9\u4e2a\u5907\u4efd\uff0c\u522b\u4eba\u662f\u53ef\u4ee5\u4e0b\u8f7d\u5230\u7684\u3002<br \/>\n2) Log into your server via SSH and cd to the directory where you\u2019ve uploaded the file.  On the (ss) plan if you<br \/>\n   uploaded the backup into your public html directory you would use the command:<br \/>\n        cd \/var\/www\/html\/<br \/>\n3) Enter the following command:<br \/>\n        <strong>mysql -u Username -p dbname < dbname.sql<\/strong><br \/>\n        \u952e\u5165\u8fd9\u884c\u547d\u4ee4<br \/>\n        &#8211; Where \u2018Username\u2019 is replaced by the mySQL username. Username\u5904\u662f\u4f60\u6570\u636e\u5e93\u7ba1\u7406\u5458\u7684\u540d\u79f0\uff0c\u540c\u4f60\u7684FTP\u767b\u5f55\u540d\u3002<br \/>\n          On (ss) plans this user is the same as the<br \/>\n          administrative FTP user.  On (as) plans this user can be found by logging into Plesk, clicking<br \/>\n          on the domain and going to databases and clicking on the database to be restored.<br \/>\n        &#8211; Replace \u2018dbname\u2019 with the name of the database to be restored. \u5c06\u88ab\u6062\u590d\u7684\u6570\u636e\u5e93\u540d\u79f0<br \/>\n        &#8211; Replace dbname.sql with the name of the backup.dbname.sql\u662f\u5907\u4efd\u6570\u636e\u5e93\u540d\u79f0<br \/>\n   If you have a zipped backup of your database you can use this line instead:\u5982\u679c\u662fZIP\u5f62\u5f0f\u7684\uff0c\u5c31\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u3002<br \/>\n        gunzip < dbname.gz | mysql -u Username -p dbname\n        - Where \u2018Username\u2019 is replaced by the mySQL username.  On (ss) plans this user is the same as the\n          administrative FTP user.  On (as) plans this user can be found by logging into Plesk, clicking\n          on the domain and going to databases and clicking on the database to be restored.\n        - Replace \u2018dbname\u2019 with the name of the database to be restored.\n        - Replace dbname.gz with the name of the backup.\n4) Enter your mySQL password at the prompt.  If you don\u2019t know it you can reset it in your webcontrol or Plesk\n   admin panel \u7136\u540e\u8f93\u5165\u5bc6\u7801\u3002\u5982\u679c\u5bf9\u4e86\u5c31\u5927\u529f\u544a\u6210\uff0c\u5982\u679c\u9519\u4e86\u5c31\u51fa\u8fd9\u4e2a\u4fe1\u606f\u4e86\u3002\n        - If you get an error that looks like this:\n                ERROR 1045: Access denied for user: \u2018Username@localhost\u2019 (Using password: YES)\n          you have entered an incorrect password, please retype it carefully or reset it to something else via\n          the webcontrol panel or Plesk  administrator\n\n\n<blockquote>\u8fd9\u91cc\u53ea\u8bf4text\u6a21\u5f0f\uff0cbinary\u6a21\u5f0f\u5148\u4e0d\u63d0\u3002<br \/>\n1.mysqldump\u5907\u4efddatabase\u6216table\uff1a<br \/>\n$mysqldump database [table1 table2] > dump.sql<br \/>\n\u6bd4\u5982\u5907\u4efd\u6570\u636e\u5e93cm2\uff1a<br \/>\n$mysqldump cm2 >cm2.sql<br \/>\n\u6216\u8005\u53ea\u662fcm2\u4e2d\u7684mail,user\u8868\uff1a<br \/>\n$mysqldump cm2 mail usrer >cm2_mail_user.sql<br \/>\nmysqldump\u53c2\u6570\u4ecb\u7ecd<br \/>\n&#8211;databases\uff1a mysqldump\u540e\u8ddf\u7684\u6240\u6709\u90fd\u662fdatabase\uff0c\u800c\u4e0d\u662ftable\u3002\u8fd9\u4e2a\u5728\u9700\u8981\u5907\u4efd\u591a\u4e2a\u6570\u636e\u5e93\u7684\u65f6\u5019\u6709\u6548\u3002<br \/>\n&#8211;all-databases\uff1a\u5907\u4efd\u6240\u6709\u7684\u6570\u636e\u5e93\u7684\u6240\u6709\u8868\u5230\u4e00\u4e2a\u6587\u4ef6<br \/>\n\u53e6\u5916\u8fd9\u4f7f\u7528\u4e24\u4e2a\u53c2\u6570\u4f1a\u81ea\u52a8\u5728\u5907\u4efd\u6587\u4ef6\u91cc\u6dfb\u52a0\u5224\u65addatabase\u662f\u5426\u5b58\u5728\uff0c\u5e76create database\u7684\u547d\u4ee4\u3002<br \/>\n\u800c\u5728\u9ed8\u8ba4\u7684\u60c5\u51b5\u4e0b\u6ca1\u6709\u6b64\u529f\u80fd\uff0c\u5982\u679c\u539f\u6765\u7684database\u6ca1\u4e86\uff0c\u9700\u8981\u5148\u521b\u5efadatabase\uff0c\u624d\u80fd\u5bfc\u5165\u3002<br \/>\n2.\u4f7f\u7528mysql\u6062\u590d\u6570\u636e\u5e93\u6216\u8868\uff1a<br \/>\n$mysql database < dump.sql\n\u6bd4\u5982\u6062\u590d\u4e4b\u524d\u5907\u4efd\u7684\u6570\u636e\u5e93cm2\n$mysql cm2 < cm2.sql\n\u5982\u679c\u6ca1\u6709\u4f7f\u7528--databases\u53c2\u6570\u5907\u4efd\uff0c\u90a3\u4e48\u5fc5\u987b\u6307\u5b9a\u6570\u636e\u5e93\uff0c\u5e76\u4e14\u8be5\u6570\u636e\u5e93\u5b58\u5728\u3002\n\u5982\u679c\u4f7f\u7528\u4e86--databases\u53c2\u6570\uff0c\u5219\u53ef\u4ee5\u4e0d\u6307\u5b9a\u6570\u636e\u5e93\uff0c\u5e76\u4e14\u6570\u636e\u5e93\u53ef\u4e0d\u5b58\u5728\u3002\n\u6240\u4ee5\u4e00\u822c\u60c5\u51b5\u5907\u4efddatabase\u7684\u60c5\u51b5\u4e0b\u52a0\u4e0a\u8fd9\u4e2a\u53c2\u6570\u4f1a\u6bd4\u8f83\u597d\u3002\n3.\u4f7f\u7528mysqldump\u548cmysql\u62f7\u8d1ddatabase\u6216\u8005table\n$mysqldump database [table] | mysql [-h other.host.com] database1\n\u8fd9\u91cccopy\u7684\u524d\u63d0\u662fdatabase1\u5fc5\u987b\u5b58\u5728\u3002\n<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>This method works regardl&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[],"class_list":["post-724","post","type-post","status-publish","format-standard","hentry","category-blog-others"],"_links":{"self":[{"href":"https:\/\/tao0.date\/index.php?rest_route=\/wp\/v2\/posts\/724","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tao0.date\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tao0.date\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tao0.date\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tao0.date\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=724"}],"version-history":[{"count":0,"href":"https:\/\/tao0.date\/index.php?rest_route=\/wp\/v2\/posts\/724\/revisions"}],"wp:attachment":[{"href":"https:\/\/tao0.date\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=724"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tao0.date\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=724"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tao0.date\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=724"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}