{"id":239,"date":"2024-11-23T09:29:27","date_gmt":"2024-11-23T01:29:27","guid":{"rendered":"https:\/\/obagg.com\/index.php\/2024\/11\/23\/mysql%e5%ae%89%e8%a3%85%e5%92%8c%e7%99%bb%e5%bd%95\/"},"modified":"2024-11-23T09:29:27","modified_gmt":"2024-11-23T01:29:27","slug":"mysql%e5%ae%89%e8%a3%85%e5%92%8c%e7%99%bb%e5%bd%95","status":"publish","type":"post","link":"https:\/\/obagg.com\/index.php\/2024\/11\/23\/mysql%e5%ae%89%e8%a3%85%e5%92%8c%e7%99%bb%e5%bd%95\/","title":{"rendered":"mysql\u5b89\u88c5\u548c\u767b\u5f55"},"content":{"rendered":"<p>Linux\uff1aubantu<\/p>\n<p>\u4e00\u3001\u5b89\u88c5\u6b65\u9aa4<br \/>\nubuntu\u4e0a\u5b89\u88c5mysql\u975e\u5e38\u7b80\u5355\u53ea\u9700\u8981\u51e0\u6761\u547d\u4ee4\u5c31\u53ef\u4ee5\u5b8c\u6210\uff1a<\/p>\n<pre><code>$sudo apt-get install mysql-server\n$apt-get isntall mysql-client\n$sudo apt-get install libmysqlclient-dev\n<\/code><\/pre>\n<p>\u5b89\u88c5\u5b8c\u6210\u4e4b\u540e\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u6765\u68c0\u67e5\u662f\u5426\u5b89\u88c5\u6210\u529f\uff1a<\/p>\n<pre><code>$sudo netstat -tanp | grep mysql\n<\/code><\/pre>\n<p>\u56de\u663e\u5982\u4e0b\uff0c\u8bf4\u660emysql \u7684socket\u5904\u4e8e listen \u72b6\u6001<\/p>\n<p>\u4e8c\u3001\u767b\u9646mysql\u6570\u636e\u5e93<\/p>\n<pre><code>mysql -u root -p\n<\/code><\/pre>\n<p>-u \u8868\u793a\u9009\u62e9\u767b\u9646\u7684\u7528\u6237\u540d\uff0c -p \u8868\u793a\u767b\u9646\u7684\u7528\u6237\u5bc6\u7801\uff0c\u4e0a\u9762\u547d\u4ee4\u8f93\u5165\u4e4b\u540e\u4f1a\u63d0\u793a\u8f93\u5165\u5bc6\u7801\uff0c\u6b64\u65f6\u8f93\u5165\u5bc6\u7801\u5c31\u53ef\u4ee5\u767b\u5f55\u5230mysql<br \/>\n\u4e0d\u51fa\u610f\u5916\u7684\u8bdd\uff0c\u5e94\u8be5\u767b\u9646\u4e0d\u4e0a\uff0c\u56e0\u4e3a\u5b89\u88c5\u8fc7\u7a0b\u672a\u8981\u6c42\u6211\u4eec\u8f93\u5165\u7528\u6237\u540d\u548c\u5bc6\u7801\uff01<\/p>\n<p>\u4e09\u3001\u67e5\u770b\u3001\u4fee\u6539\u7cfb\u7edf\u914d\u7f6e\u6587\u4ef6<br \/>\n\uff08\u6839\u76ee\u5f55\u64cd\u4f5c\uff09[email protected]:~# vim \/etc\/mysql\/debian.cnf<br \/>\n\uff08\u4e0d\u662f\u6839\u76ee\u5f55\u64cd\u4f5c\uff09sudo vim \/etc\/mysql\/debian.cnf<br \/>\n\u8bf7\u4ee5\u7ba1\u7406\u5458\u6743\u9650\u67e5\u770b\u5982\u4e0a\u6587\u4ef6\uff0c\u5426\u5219\u6253\u5f00\u540e\u5185\u5bb9\u4e3a\u7a7a\uff01<br \/>\n\u627e\u5230\u7c7b\u662f\u4e0b\u9762\u7684\u7528\u6237\u548c\u5bc6\u7801<\/p>\n<pre><code> user = debian-sys-maint\npassword = FDMzQT66HDZpi4B5\n<\/code><\/pre>\n<p>\u7528mysql\u63d0\u4f9b\u7684\u7528\u6237\u548c\u5bc6\u7801\u767b\u5f55<br \/>\n\u5982\u679c\u8fdb\u4e0d\u53bb\u4f7f\u7528$ sudo  mysql -u debian-sys-maint -p<\/p>\n<p>\u56db\u3001\u4fee\u6539\u5bc6\u7801<br \/>\n\u4fee\u6539\u5bc6\u7801\uff08\u5047\u5982\u4fee\u6539\u5bc6\u7801\u4e3a\uff1a123456#Abc\uff09<\/p>\n<blockquote>\n<p>use mysql;<br \/>\nmysql5.7\u53ef\u4ee5\u4f7f\u7528\uff1a<br \/>\nupdate mysql.user set authentication_string=password(&#8216;123456#Abc&#8217;)  where user=&#8217;root&#8217;<br \/>\nmysql 8\u4f7f\u7528\uff1a<br \/>\nupdate user set authentication_string=&#8217;123456#Abc&#8217;  where  user=&#8217;root&#8217;;<\/p>\n<\/blockquote>\n<p>\u4e94\u3001\u6dfb\u52a0\u7528\u6237<br \/>\n\u5047\u8bbe\u4f60\u8fdb\u5165mysql<br \/>\n\u6dfb\u52a0test\u7528\u6237\uff0c\u5bc6\u7801123456<\/p>\n<blockquote>\n<p>insert into mysql.user(Host,User,authentication_string) values(&#8220;localhost&#8221;,&#8221;test&#8221;,password(&#8220;123456&#8221;));<\/p>\n<\/blockquote>\n<p>\u516d\u3001\u67e5\u770b\u7528\u6237<br \/>\n\u6267\u884cuse mysql\uff1b\uff08\u4e4b\u524d\u6709\u6267\u884c\u5c31\u4e0d\u7528\u4e86\uff09<\/p>\n<blockquote>\n<p>select user from user;<\/p>\n<\/blockquote>\n<h2>windows<\/h2>\n<p>1\u3001\u5de6\u4e0b\u89d2\u641c\u7d22\u680f\u8f93\u5165cmd\u5e76\u4ee5\u7ba1\u7406\u5458\u8eab\u4efd\u6253\u5f00\u547d\u4ee4\u884c\u7a97\u53e3\uff0c\u5207\u6362\u5230mysql\u7684bin\u8def\u5f84\u4e0b\uff0c\u4f9d\u6b21\u8f93\u5165\u201cmysqld &#8211;initialize\u201d\u548c\u201cmysqld &#8211;install\u201dim\u547d\u4ee4\u3002 2\u3001\u8f93\u5165\u201cnet start mysql\u201d\u542f\u52a8mysql\uff0c\u8f93\u5165\u201cmysql -u root -p\u201d\u767b\u5f55\u3002 3\u3001\u5728mysql\u547d\u4ee4\u884c\u8f93\u5165\u4e0b\u9762\u4e24\u884c\u547d\u4ee4\u8bbe\u7f6e\u5bc6\u7801\u3002<\/p>\n<p>Please credit: <a href=\"https:\/\/obagg.com\">OBA Blog<\/a> &raquo; <a href=\"https:\/\/obagg.com\/index.php\/2024\/11\/23\/mysql%e5%ae%89%e8%a3%85%e5%92%8c%e7%99%bb%e5%bd%95\/\">mysql\u5b89\u88c5\u548c\u767b\u5f55<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>Linux\uff1aubantu \u4e00\u3001\u5b89\u88c5\u6b65\u9aa4 ubuntu\u4e0a\u5b89\u88c5mysql\u975e\u5e38\u7b80\u5355\u53ea\u9700\u8981\u51e0\u6761\u547d\u4ee4\u5c31\u53ef\u4ee5\u5b8c\u6210\uff1a $sudo apt-get install mysql-server $apt-get isntall mysql-client $sudo apt-get install libmysqlclient-dev \u5b89\u88c5\u5b8c\u6210\u4e4b\u540e\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u6765\u68c0\u67e5\u662f\u5426\u5b89\u88c5\u6210\u529f\uff1a $sudo netstat -tanp | grep mysql \u56de\u663e\u5982\u4e0b\uff0c\u8bf4\u660emysql \u7684socket\u5904\u4e8e listen \u72b6\u6001 \u4e8c\u3001\u767b\u9646mysql\u6570\u636e\u5e93 mysql -u root -p -u \u8868\u793a\u9009\u62e9\u767b\u9646\u7684\u7528\u6237\u540d\uff0c -p \u8868\u793a\u767b\u9646\u7684\u7528\u6237\u5bc6\u7801\uff0c\u4e0a\u9762\u547d\u4ee4\u8f93\u5165\u4e4b\u540e\u4f1a\u63d0\u793a\u8f93\u5165\u5bc6\u7801\uff0c\u6b64\u65f6\u8f93\u5165\u5bc6\u7801\u5c31\u53ef\u4ee5\u767b\u5f55\u5230mysql \u4e0d\u51fa\u610f\u5916\u7684\u8bdd\uff0c\u5e94\u8be5\u767b\u9646\u4e0d\u4e0a\uff0c\u56e0\u4e3a\u5b89\u88c5\u8fc7\u7a0b\u672a\u8981\u6c42\u6211\u4eec\u8f93\u5165\u7528\u6237\u540d\u548c\u5bc6\u7801\uff01 \u4e09\u3001\u67e5\u770b\u3001\u4fee\u6539\u7cfb\u7edf\u914d\u7f6e\u6587\u4ef6 \uff08\u6839\u76ee\u5f55\u64cd\u4f5c\uff09[email protected]:~# vim \/etc\/mysql\/debian.cnf \uff08\u4e0d\u662f\u6839\u76ee\u5f55\u64cd\u4f5c\uff09sudo vim \/etc\/mysql\/debian.cnf \u8bf7\u4ee5\u7ba1\u7406\u5458\u6743\u9650\u67e5\u770b\u5982\u4e0a\u6587\u4ef6\uff0c\u5426\u5219\u6253\u5f00\u540e\u5185\u5bb9\u4e3a\u7a7a\uff01 \u627e\u5230\u7c7b\u662f\u4e0b\u9762\u7684\u7528\u6237\u548c\u5bc6\u7801 user = debian-sys-maint password = FDMzQT66HDZpi4B5 \u7528mysql\u63d0\u4f9b\u7684\u7528\u6237\u548c\u5bc6\u7801\u767b\u5f55 \u5982\u679c\u8fdb\u4e0d\u53bb\u4f7f\u7528$ sudo mysql -u debian-sys-maint -p \u56db\u3001\u4fee\u6539\u5bc6\u7801 \u4fee\u6539\u5bc6\u7801\uff08\u5047\u5982\u4fee\u6539\u5bc6\u7801\u4e3a\uff1a123456#Abc\uff09 use mysql; mysql5.7\u53ef\u4ee5\u4f7f\u7528\uff1a update mysql.user set authentication_string=password(&#8216;123456#Abc&#8217;) where user=&#8217;root&#8217; mysql 8\u4f7f\u7528\uff1a update user set authentication_string=&#8217;123456#Abc&#8217; where user=&#8217;root&#8217;; \u4e94\u3001\u6dfb\u52a0\u7528\u6237 \u5047\u8bbe\u4f60\u8fdb\u5165mysql \u6dfb\u52a0test\u7528\u6237\uff0c\u5bc6\u7801123456 insert into mysql.user(Host,User,authentication_string) values(&#8220;localhost&#8221;,&#8221;test&#8221;,password(&#8220;123456&#8221;)); \u516d\u3001\u67e5\u770b\u7528\u6237 \u6267\u884cuse mysql\uff1b\uff08\u4e4b\u524d\u6709\u6267\u884c\u5c31\u4e0d\u7528\u4e86\uff09 select user from user; windows 1\u3001\u5de6\u4e0b\u89d2\u641c\u7d22\u680f\u8f93\u5165cmd\u5e76\u4ee5\u7ba1\u7406\u5458\u8eab\u4efd\u6253\u5f00\u547d\u4ee4\u884c\u7a97\u53e3\uff0c\u5207\u6362\u5230mysql\u7684bin\u8def\u5f84\u4e0b\uff0c\u4f9d\u6b21\u8f93\u5165\u201cmysqld &#8211;initialize\u201d\u548c\u201cmysqld &#8211;install\u201dim\u547d\u4ee4\u3002 2\u3001\u8f93\u5165\u201cnet start mysql\u201d\u542f\u52a8mysql\uff0c\u8f93\u5165\u201cmysql -u root -p\u201d\u767b\u5f55\u3002 3\u3001\u5728mysql\u547d\u4ee4\u884c\u8f93\u5165\u4e0b\u9762\u4e24\u884c\u547d\u4ee4\u8bbe\u7f6e\u5bc6\u7801\u3002 Please credit: OBA Blog &raquo; mysql\u5b89\u88c5\u548c\u767b\u5f55<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-239","post","type-post","status-publish","format-standard","hentry","category-share"],"_links":{"self":[{"href":"https:\/\/obagg.com\/index.php\/wp-json\/wp\/v2\/posts\/239","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/obagg.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/obagg.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/obagg.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/obagg.com\/index.php\/wp-json\/wp\/v2\/comments?post=239"}],"version-history":[{"count":0,"href":"https:\/\/obagg.com\/index.php\/wp-json\/wp\/v2\/posts\/239\/revisions"}],"wp:attachment":[{"href":"https:\/\/obagg.com\/index.php\/wp-json\/wp\/v2\/media?parent=239"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/obagg.com\/index.php\/wp-json\/wp\/v2\/categories?post=239"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/obagg.com\/index.php\/wp-json\/wp\/v2\/tags?post=239"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}