{"id":47,"date":"2021-03-13T12:11:24","date_gmt":"2021-03-13T04:11:24","guid":{"rendered":"http:\/\/daishen.ltd\/?p=47"},"modified":"2021-03-13T12:11:25","modified_gmt":"2021-03-13T04:11:25","slug":"mysql%e5%ae%89%e8%a3%85%e4%bb%a5%e5%8f%8a%e5%88%9d%e5%a7%8b%e5%8c%96","status":"publish","type":"post","link":"https:\/\/daishen.ltd\/?p=47","title":{"rendered":"mysql\u5b89\u88c5\u4ee5\u53ca\u521d\u59cb\u5316"},"content":{"rendered":"<p><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width initial-scale=1\"><br \/>\n<title>mysql\u5b89\u88c5\u4ee5\u53ca\u521d\u59cb\u5316<\/title><\/p>\n<h4>\u521b\u5efa\u5e94\u7528\u76ee\u5f55<\/h4>\n<pre><code class=\"language-shell\" lang=\"shell\">mkdir -p \/server\/tools\nmkdir -p \/application\n<\/code><\/pre>\n<h4>\u4e0b\u8f7dMySQL\u4e8c\u8fdb\u5236\u5305<\/h4>\n<pre><code class=\"language-shell\" lang=\"shell\">wget https:\/\/cdn.mysql.com\/archives\/mysql-5.7\/mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz\n<\/code><\/pre>\n<h4>\u89e3\u538b\uff0c\u79fb\u52a8<\/h4>\n<pre><code class=\"language-shell\" lang=\"shell\">tar vxf mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz\n\nmv mysql-5.7.26-linux-glibc2.12-x86_64 \/application\/mysql\n\ncd \/application\/mysql \n<\/code><\/pre>\n<h4>\u521b\u5efaMySQL\u7528\u6237\u4ee5\u53ca\u5904\u7406\u539f\u59cb\u73af\u5883<\/h4>\n<pre><code class=\"language-shell\" lang=\"shell\">yum remove mariadb\n\nuseradd -s \/sbin\/nologin mysql\n<\/code><\/pre>\n<h4>\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf<\/h4>\n<pre><code class=\"language-shell\" lang=\"shell\">vim \/etc\/profile\n\nexport PATH=\/application\/mysql\/bin:$PATH\n\nsource \/etc\/profile\n\nmysql -V\n<\/code><\/pre>\n<h4>\u6dfb\u52a0\u65b0\u78c1\u76d8\uff0c\u683c\u5f0f\u5316\u5e76\u6302\u8f7d\u78c1\u76d8<\/h4>\n<pre><code class=\"language-shell\" lang=\"shell\">fdisk -l                       #\u67e5\u770b\u6240\u6709\u78c1\u76d8\nmkfs.xfs \/dev\/sdb\nmkdir \/data\nblkid\nvim \/etc\/fstab\n\nUUID=\"9cae8337-79e4-4300-aa46-38a5ff99c015\"    \/data  xfs  defaults  0  0\n\nmount -a\ndf -h\n<\/code><\/pre>\n<h4>\u6388\u6743,\u66f4\u6539\u5c5e\u4e3b\u5c5e\u7ec4<\/h4>\n<pre><code class=\"language-shell\" lang=\"shell\">chown -R mysql.mysql \/application\/*\nchown -R mysql.mysql \/data\n<\/code><\/pre>\n<h4>\u521d\u59cb\u5316\u6570\u636e\uff08\u521b\u5efa\u7cfb\u7edf\u6570\u636e\uff09<\/h4>\n<pre><code class=\"language-shell\" lang=\"shell\">5.6\u7248\u672c \u521d\u59cb\u5316\u547d\u4ee4 \/app1ication\/mysql\/scripts\/mysql_install_db\n5.7\u7248\u672c\uff1a\nmkdir \/data\/mysql\/data -p\nchown -R mysql.mysql \/data\nmysqld --initialize --user=mysql --basedir=\/application\/mysql --datadir=\/data\/mysql\/data\n\n# --initialize \u53c2\u6570:\n#1.\u5bf9\u4e8e\u5bc6\u7801\u590d\u6742\u5ea6\u8fdb\u884c\u5b9a\u5236:12\u4f4d\uff0c4\u79cd\n#2.\u5bc6\u7801\u8fc7\u671f\u65f6\u95f4:180\n#3.\u7ed9root@localhost\u7528\u6237\u8bbe\u7f6e\u4e34\u65f6\u5bc6\u7801\n\n2020-11-15T08:02:09.982496Z 1 [Note] A temporary password is generated for root@localhost: 8wy!d4=%wl1M\n\n8wy!d4=%wl1M \u4e34\u65f6\u5bc6\u7801\n\n#--initialize-insecure \u53c2\u6570:\n#\u65e0\u9650\u5236\uff0c\u65e0\u4e34\u65f6\u5bc6\u7801\n \\rm -rf \/data\/mysql\/data\/*\nmysqld --initialize-insecure --user=mysql --basedir=\/application\/mysql --datadir=\/data\/mysql\/data\n<\/code><\/pre>\n<h4>\u914d\u7f6e\u6587\u4ef6\u51c6\u5907<\/h4>\n<pre><code class=\"language-shell\" lang=\"shell\">cat &gt;\/etc\/my.cnf &lt;&lt;EOF\n[mysqld]\nuser=mysql\nbasedir=\/application\/mysql \ndatadir=\/data\/mysql\/data\nsocket=\/tmp\/mysql.sock\nserver_id=6\nport=3306\n[mysql]\nsocket=\/tmp\/mysql.sock\nEOF\n<\/code><\/pre>\n<h4>\u542f\u52a8\u6570\u636e\u5e93<\/h4>\n<pre><code class=\"language-shell\" lang=\"shell\">#sys-v\u542f\u52a8\u65b9\u5f0f\ncp \/application\/mysql\/support-files\/mysql.server \/etc\/init.d\/mysqld\nservice mysqld restart\n\n#systemd\u542f\u52a8\u65b9\u5f0f\ncat &gt;\/etc\/systemd\/system\/mysqld.service &lt;&lt;EOF\n[Unit]\nDescription=MySQL Server\nDocumentation=man:mysqld(8)\nDocumentation=http:\/\/dev.mysql.com\/doc\/refman\/en\/using-systemd.htm1\nAfter=network.target\nAfter=syslog.target\n[Install]\nWantedBy=multi--user.target\n[Service]\nUser=mysql\nGroup=mysql\nExecStart=\/app1ication\/mysql\/bin\/mysqld --defaults-file=\/etc\/my.cnf\nLimitNOFILE=5000\nEOF\n\nsystemctl start mysqld\n#\u67e5\u770b\u542f\u52a8\u8fdb\u7a0b\u7aef\u53e3\nnetstat -lnp|grep 3306\n\nps -ef|grep 3306\n\n<\/code><\/pre>\n<h4>\u5982\u4f55\u5206\u6790\u5904\u7406MySQL\u6570\u636e\u5e93\u65e0\u6cd5\u542f\u52a8<\/h4>\n<ul>\n<li>without updating PID\u7c7b\u4f3c\u9519\u8bef<br \/>\n\u67e5\u770b\u65e5\u5fd7:<br \/>\n\/data\/mysql\/data\/\u4e3b\u673a\u540d.err<br \/>\n[ERROR]\u4e0a\u4e0b\u6587<\/li>\n<li>\u53ef\u80fd\u60c5\u51b5:<br \/>\n\/etc\/my .cnf\u8def\u5f84\u4e0d\u5bf9\u7b49<br \/>\n\/ tmp\/mysql.sock\u6587\u4ef6\u4fee\u6539\u8fc7\u6216\u5220\u9664\u8fc7<br \/>\n\u6570\u636e\u76ee\u5f55\u6743\u9650\u4e0d\u662fmysql<br \/>\n\u53c2\u6570\u6539\u9519\u4e86<\/li>\n<\/ul>\n<h4>\u7ba1\u7406\u5458\u5bc6\u7801\u8bbe\u7f6e\uff08root@localhost\uff09<\/h4>\n<pre><code class=\"language-shell\" lang=\"shell\">mysqladmin -u root -p password 'l723433302'\n<\/code><\/pre>\n<h4>\u7ba1\u7406\u5458\u5fd8\u8bb0\u5bc6\u7801\u64cd\u4f5c<\/h4>\n<pre><code class=\"language-shell\" lang=\"shell\">1\uff0c\u5173\u95ed\u6570\u636e\u5e93\nservice mysqld stop  \n\n2\uff0c\u542f\u52a8\u6570\u636e\u5e93\u5230\u7ef4\u62a4\u6a21\u5f0f\nmysqld_safe --skip-grant-tables --skip-networking &amp;\n\n3\uff0c\u767b\u5f55\u5e76\u4fee\u6539\u5bc6\u7801\nmysql\n\nselect user,host,authentication_string from mysql.user;\n\nflush privileges;\n\ngrant all on *.* to root@'localhost' identified by 'l723433302';\ngrant all on *.* to HAIRUI@'%' identified by 'l723433302';\n\n4\uff0c\u5173\u95ed\u6570\u636e\u5e93\uff0c\u6b63\u5e38\u542f\u52a8\u9a8c\u8bc1\n\n\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>mysql\u5b89\u88c5\u4ee5\u53ca\u521d\u59cb\u5316 \u521b\u5efa\u5e94\u7528\u76ee\u5f55 mkdir -p \/server\/tools mkdir -p \/ap [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-47","post","type-post","status-publish","format-standard","hentry","category-mysql"],"_links":{"self":[{"href":"https:\/\/daishen.ltd\/index.php?rest_route=\/wp\/v2\/posts\/47","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/daishen.ltd\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/daishen.ltd\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/daishen.ltd\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/daishen.ltd\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=47"}],"version-history":[{"count":1,"href":"https:\/\/daishen.ltd\/index.php?rest_route=\/wp\/v2\/posts\/47\/revisions"}],"predecessor-version":[{"id":48,"href":"https:\/\/daishen.ltd\/index.php?rest_route=\/wp\/v2\/posts\/47\/revisions\/48"}],"wp:attachment":[{"href":"https:\/\/daishen.ltd\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=47"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/daishen.ltd\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=47"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/daishen.ltd\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=47"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}