{"id":2815,"date":"2012-03-29T10:18:25","date_gmt":"2012-03-29T02:18:25","guid":{"rendered":"http:\/\/jpuyy.com\/?p=2815"},"modified":"2014-01-09T20:26:39","modified_gmt":"2014-01-09T12:26:39","slug":"mysql-change-root-password","status":"publish","type":"post","link":"https:\/\/jpuyy.com\/?p=2815","title":{"rendered":"mysql\uff08\u5df2\u77e5\u65e7\u5bc6\u7801\uff09\u4fee\u6539\u5bc6\u7801\u7684\u4e24\u79cd\u65b9\u6cd5"},"content":{"rendered":"<p><a href=\"http:\/\/www.cyberciti.biz\/faq\/mysql-change-root-password\/\">http:\/\/www.cyberciti.biz\/faq\/mysql-change-root-password\/<\/a><\/p>\n<p>\u8fd9\u91cc\u7684\u524d\u63d0\u662f\u4f60\u80fd\u767b\u7684\u8fdbmysql<\/p>\n<h2>\u65b9\u6cd5\u4e00\uff1a\u7528mysqladmin\u547d\u4ee4\u4fee\u6539root\u5bc6\u7801<\/h2>\n<p>\u5982\u679c\u4f60\u88c5mysql\u7684\u65f6\u5019\u7528\u7684\u7a7a\u5bc6\u7801\uff0c\u73b0\u5728\u8981\u8bbe\u5b9a\u4e00\u4e2a\u521d\u59cb\u5bc6\u7801\uff0c\u90a3\u4e48\u6267\u884c\uff1aIf you have never set a root password for MySQL server, the server does not require a password at all for connecting as root. To setup root password for first time, use mysqladmin command at shell prompt as follows:<\/p>\n<pre>$ mysqladmin -u root password NEWPASSWORD<\/pre>\n<p>\u4f60\u60f3\u8981\u66f4\u65b0\u5bc6\u7801\uff0c\u7528\u5982\u4e0b\u547d\u4ee4\uff0cHowever, if you want to change (or update) a root password, then you need to use the following command:<\/p>\n<pre>$ mysqladmin -u root -p'oldpassword' password newpass<\/pre>\n<p>\u4f8b\u5982\uff0c\u65e7\u5bc6\u7801\u662fabc\uff0c\u65b0\u5bc6\u7801\u662f123456\uff0c\u5219\u8f93\u5165\uff0cFor example, If the old password is abc, you can set the new password to 123456, enter:<\/p>\n<pre>$ mysqladmin -u root -p'abc' password '123456'<\/pre>\n<p>\u66f4\u6539\u5176\u4ed6\u7528\u6237\u7684\u5bc6\u7801\uff0cChange MySQL password for other users<\/p>\n<p>\u5982\u66f4\u6539\u666e\u901a\u7528\u6237\u5bc6\u7801\uff0c\u7528\u5982\u4e0b\u547d\u4ee4\uff0cTo change a normal user password you need to type (let us assume you would like to change password for user vivek) the following command:<\/p>\n<pre>$ mysqladmin -u vivek -p oldpassword password newpass<\/pre>\n<h3>\u65b9\u6cd5\u4e8c\uff1a\u7528mysql\u7684sql\u8bed\u8a00\u6765\u66f4\u6539root\u5bc6\u7801<\/h3>\n<p>Changing MySQL root user password using MySQL sql command<\/p>\n<p>\u5728mysql\u6570\u636e\u5e93\u4e2d\u4fdd\u5b58\u4e86root\u7684\u5bc6\u7801\uff0cThis is another method. MySQL stores username and passwords in user table inside MySQL database. You can directly update password using the following method to update or change password for user vivek:<\/p>\n<p>1)\u7528root\u767b\u9646 Login to mysql server, type the following command at shell prompt:<\/p>\n<pre>$ mysql -u root -p<\/pre>\n<p>2) \u5207\u6362\u5230mysql\u6570\u636e\u5e93\uff0cUse mysql database (type command at mysql&gt; prompt):<\/p>\n<pre>mysql&gt; use mysql;<\/pre>\n<p>3) \u66f4\u65b0vivek\u7684\u5bc6\u7801Change password for user vivek, enter:<\/p>\n<pre>mysql&gt; update user set password=PASSWORD(\"NEWPASSWORD\") where User='vivek';<\/pre>\n<p>4) \u6700\u540e\u5237\u65b0\u6743\u9650\uff0cFinally, reload the privileges:<\/p>\n<pre>mysql&gt; flush privileges;\r\nmysql&gt; quit<\/pre>\n<p>\u540e\u4e00\u79cd\u65b9\u6cd5\u53ef\u4ee5\u7528\u5728php,python\u548cperl\u4e2d<br \/>\nThe last method can be used with PHP, Python or Perl scripting mysql API.<\/p>\n<p>2014-01-09\u66f4\u65b0\uff1a<\/p>\n<p>\u6267\u884cSET PASSWORD\u547d\u4ee4\uff0c\u66f4\u6539\u00a0&#8216;jpuyy&#8217;@&#8217;localhost&#8217;<\/p>\n<pre>SET PASSWORD FOR 'jpuyy'@'localhost' = PASSWORD('password');<\/pre>\n<p>\u5982\u679c\u662f\u66f4\u6539\u81ea\u5df1\u7684\u5bc6\u7801\uff0c\u53ef\u7701\u7565for\u8bed\u53e5<\/p>\n<pre>SET PASSWORD = PASSWORD('password');<\/pre>\n<p>\u8fd8\u53ef\u4ee5\u4f7f\u7528GRANT USAGE(\u5728*.*)\u6765\u6307\u5b9a\u67d0\u4e2a\u8d26\u53f7\u7684\u5bc6\u7801\u800c\u4e0d\u5f71\u54cd\u8d26\u6237\u5f53\u524d\u7684\u6743\u9650\u3002<\/p>\n<pre>GRANT USAGE ON *.* TO 'jpuyy'@'localhost' IDENTIFIED BY 'password';<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>http:\/\/www.cyberciti.biz\/faq\/mysql-change-root-password\/ \u8fd9\u91cc\u7684\u524d\u63d0\u662f\u4f60\u80fd\u767b\u7684\u8fdbmysql \u65b9\u6cd5\u4e00\uff1a\u7528mysqladmin\u547d\u4ee4\u4fee\u6539root\u5bc6\u7801 \u5982\u679c\u4f60\u88c5mysql\u7684\u65f6\u5019\u7528\u7684\u7a7a\u5bc6\u7801\uff0c\u73b0\u5728\u8981\u8bbe\u5b9a\u4e00\u4e2a\u521d\u59cb\u5bc6\u7801\uff0c\u90a3\u4e48\u6267\u884c\uff1aIf you have never set a root password for MySQL server, the server does not require a password at all for connecting as root. To setup root password for first time, use mysqladmin command at shell prompt as follows: $ mysqladmin -u root password NEWPASSWORD \u4f60\u60f3\u8981\u66f4\u65b0\u5bc6\u7801\uff0c\u7528\u5982\u4e0b\u547d\u4ee4\uff0cHowever, if you want to change (or [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[65],"tags":[],"class_list":["post-2815","post","type-post","status-publish","format-standard","hentry","category-mysql"],"_links":{"self":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/2815","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2815"}],"version-history":[{"count":14,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/2815\/revisions"}],"predecessor-version":[{"id":6092,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/2815\/revisions\/6092"}],"wp:attachment":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2815"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2815"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2815"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}