-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path7eed2d06.8265236f.js
More file actions
1 lines (1 loc) · 11.9 KB
/
7eed2d06.8265236f.js
File metadata and controls
1 lines (1 loc) · 11.9 KB
1
(window.webpackJsonp=window.webpackJsonp||[]).push([[28],{96:function(e,t,l){"use strict";l.r(t),l.d(t,"frontMatter",(function(){return r})),l.d(t,"metadata",(function(){return c})),l.d(t,"rightToc",(function(){return i})),l.d(t,"default",(function(){return o}));var n=l(2),a=l(6),s=(l(0),l(130)),r={layout:"wiki",title:"MySQL\u57fa\u672c\u5b89\u88c5"},c={unversionedId:"prepare/mysql",id:"prepare/mysql",isDocsHomePage:!1,title:"MySQL\u57fa\u672c\u5b89\u88c5",description:"\u672c\u6587\u4e3b\u8981\u8bf4\u660emysql\u5728\u4e2a\u5e73\u53f0\u7684\u5b89\u88c5\u8bf4\u660e",source:"@site/docs/prepare/mysql.md",slug:"/prepare/mysql",permalink:"/docs/prepare/mysql",version:"current",sidebar:"docs",previous:{title:"\u9001\u8fbe\u4e0e\u5df2\u8bfb\u56de\u6267\u7684\u8bbe\u8ba1\u65b9\u6848\u8bf4\u660e",permalink:"/docs/concept/delivery-read-report"},next:{title:"Minio\u57fa\u672c\u5b89\u88c5\u8bf4\u660e",permalink:"/docs/prepare/minio"}},i=[{value:"CentOS 6.5/6.6 \u5b89\u88c5\uff08install\uff09mysql 5.7 \u6700\u5b8c\u6574\u7248\u6559\u7a0b",id:"centos-6566-\u5b89\u88c5\uff08install\uff09mysql-57-\u6700\u5b8c\u6574\u7248\u6559\u7a0b",children:[{value:"Step1: \u68c0\u6d4b\u7cfb\u7edf\u662f\u5426\u81ea\u5e26\u5b89\u88c5mysql",id:"step1-\u68c0\u6d4b\u7cfb\u7edf\u662f\u5426\u81ea\u5e26\u5b89\u88c5mysql",children:[]},{value:"Step2: \u5220\u9664\u7cfb\u7edf\u81ea\u5e26\u7684mysql\u53ca\u5176\u4f9d\u8d56",id:"step2-\u5220\u9664\u7cfb\u7edf\u81ea\u5e26\u7684mysql\u53ca\u5176\u4f9d\u8d56",children:[]},{value:"Step3: \u7ed9CentOS\u6dfb\u52a0rpm\u6e90\uff0c\u5e76\u4e14\u9009\u62e9\u8f83\u65b0\u7684\u6e90",id:"step3-\u7ed9centos\u6dfb\u52a0rpm\u6e90\uff0c\u5e76\u4e14\u9009\u62e9\u8f83\u65b0\u7684\u6e90",children:[]},{value:"Step4:\u5b89\u88c5mysql \u670d\u52a1\u5668",id:"step4\u5b89\u88c5mysql-\u670d\u52a1\u5668",children:[]},{value:"Step6: \u67e5\u770bmysql\u662f\u5426\u81ea\u542f\u52a8,\u5e76\u4e14\u8bbe\u7f6e\u5f00\u542f\u81ea\u542f\u52a8",id:"step6-\u67e5\u770bmysql\u662f\u5426\u81ea\u542f\u52a8\u5e76\u4e14\u8bbe\u7f6e\u5f00\u542f\u81ea\u542f\u52a8",children:[]},{value:"Step7: mysql\u5b89\u5168\u8bbe\u7f6e",id:"step7-mysql\u5b89\u5168\u8bbe\u7f6e",children:[]}]},{value:"Myql\u5907\u4efd\u4e0e\u6062\u590d",id:"myql\u5907\u4efd\u4e0e\u6062\u590d",children:[{value:"\u5907\u4efd",id:"\u5907\u4efd",children:[]},{value:"\u6062\u590d",id:"\u6062\u590d",children:[]}]},{value:"Unbuntu 18.04",id:"unbuntu-1804",children:[{value:"Prerequisites",id:"prerequisites",children:[]},{value:"Step 2 \u2014 Configuring MySQL",id:"step-2--configuring-mysql",children:[]},{value:"\u6388\u6743\u8bbf\u95ee",id:"\u6388\u6743\u8bbf\u95ee",children:[]}]},{value:"\u53c2\u8003\u8d44\u6599",id:"\u53c2\u8003\u8d44\u6599",children:[]}],b={rightToc:i};function o(e){var t=e.components,l=Object(a.a)(e,["components"]);return Object(s.b)("wrapper",Object(n.a)({},b,l,{components:t,mdxType:"MDXLayout"}),Object(s.b)("p",null,"\u672c\u6587\u4e3b\u8981\u8bf4\u660emysql\u5728\u4e2a\u5e73\u53f0\u7684\u5b89\u88c5\u8bf4\u660e"),Object(s.b)("h2",{id:"centos-6566-\u5b89\u88c5\uff08install\uff09mysql-57-\u6700\u5b8c\u6574\u7248\u6559\u7a0b"},"CentOS 6.5/6.6 \u5b89\u88c5\uff08install\uff09mysql 5.7 \u6700\u5b8c\u6574\u7248\u6559\u7a0b"),Object(s.b)("h3",{id:"step1-\u68c0\u6d4b\u7cfb\u7edf\u662f\u5426\u81ea\u5e26\u5b89\u88c5mysql"},"Step1: \u68c0\u6d4b\u7cfb\u7edf\u662f\u5426\u81ea\u5e26\u5b89\u88c5mysql"),Object(s.b)("pre",null,Object(s.b)("code",Object(n.a)({parentName:"pre"},{}),"# yum list installed | grep mysql\n")),Object(s.b)("h3",{id:"step2-\u5220\u9664\u7cfb\u7edf\u81ea\u5e26\u7684mysql\u53ca\u5176\u4f9d\u8d56"},"Step2: \u5220\u9664\u7cfb\u7edf\u81ea\u5e26\u7684mysql\u53ca\u5176\u4f9d\u8d56"),Object(s.b)("p",null,"\u547d\u4ee4\uff1a"),Object(s.b)("pre",null,Object(s.b)("code",Object(n.a)({parentName:"pre"},{}),"# yum -y remove mysql-libs.x86_64\n")),Object(s.b)("h3",{id:"step3-\u7ed9centos\u6dfb\u52a0rpm\u6e90\uff0c\u5e76\u4e14\u9009\u62e9\u8f83\u65b0\u7684\u6e90"},"Step3: \u7ed9CentOS\u6dfb\u52a0rpm\u6e90\uff0c\u5e76\u4e14\u9009\u62e9\u8f83\u65b0\u7684\u6e90"),Object(s.b)("p",null,"\u547d\u4ee4\uff1a"),Object(s.b)("pre",null,Object(s.b)("code",Object(n.a)({parentName:"pre"},{}),"# wget dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm\n# yum localinstall mysql-community-release-el6-5.noarch.rpm\n# yum repolist all | grep mysql\n# yum-config-manager --disable mysql55-community\n# yum-config-manager --disable mysql56-community\n# yum-config-manager --enable mysql57-community-dmr\n# yum repolist enabled | grep mysql\n")),Object(s.b)("p",null,Object(s.b)("strong",{parentName:"p"},"NOTE:"),"\u8fd9\u91cc\u53ef\u4ee5\u67e5\u770b\u8981\u5b89\u88c5\u7684mysql\u7248\u672c\uff0c\u53ef\u4ee5\u542f\u52a8\u7981\u7528\u9009\u62e9\u7684\u7248\u672c"),Object(s.b)("h3",{id:"step4\u5b89\u88c5mysql-\u670d\u52a1\u5668"},"Step4:\u5b89\u88c5mysql \u670d\u52a1\u5668"),Object(s.b)("p",null,"\u547d\u4ee4\uff1a"),Object(s.b)("pre",null,Object(s.b)("code",Object(n.a)({parentName:"pre"},{}),"# yum install mysql-community-server\n")),Object(s.b)("p",null,"Step5: \u542f\u52a8mysql\n\u547d\u4ee4:"),Object(s.b)("pre",null,Object(s.b)("code",Object(n.a)({parentName:"pre"},{}),"# service mysqld start\n")),Object(s.b)("h3",{id:"step6-\u67e5\u770bmysql\u662f\u5426\u81ea\u542f\u52a8\u5e76\u4e14\u8bbe\u7f6e\u5f00\u542f\u81ea\u542f\u52a8"},"Step6: \u67e5\u770bmysql\u662f\u5426\u81ea\u542f\u52a8,\u5e76\u4e14\u8bbe\u7f6e\u5f00\u542f\u81ea\u542f\u52a8"),Object(s.b)("p",null,"\u547d\u4ee4:"),Object(s.b)("pre",null,Object(s.b)("code",Object(n.a)({parentName:"pre"},{}),"# chkconfig --list | grep mysqld\n# chkconfig mysqld on\n")),Object(s.b)("h3",{id:"step7-mysql\u5b89\u5168\u8bbe\u7f6e"},"Step7: mysql\u5b89\u5168\u8bbe\u7f6e"),Object(s.b)("p",null,"\u547d\u4ee4\uff1a"),Object(s.b)("pre",null,Object(s.b)("code",Object(n.a)({parentName:"pre"},{}),"# mysql_secure_installation\n")),Object(s.b)("p",null,Object(s.b)("strong",{parentName:"p"},"NOTE:")," \u8fd9\u91cc\u63d0\u4f9b\u5bf9\u8bdd\u5f0f\u7684\u9009\u62e9\u914d\u7f6e\u8bbe\u7f6e\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u66f4\u6539root\u7528\u6237\u5bc6\u7801 ",Object(s.b)("inlineCode",{parentName:"p"},"mysqladmin -u root password 'root'")),Object(s.b)("h2",{id:"myql\u5907\u4efd\u4e0e\u6062\u590d"},"Myql\u5907\u4efd\u4e0e\u6062\u590d"),Object(s.b)("h3",{id:"\u5907\u4efd"},"\u5907\u4efd"),Object(s.b)("pre",null,Object(s.b)("code",Object(n.a)({parentName:"pre"},{className:"language-shell"}),"mysqldump -uroot -p wfchat > wfchat.sql\n")),Object(s.b)("h3",{id:"\u6062\u590d"},"\u6062\u590d"),Object(s.b)("pre",null,Object(s.b)("code",Object(n.a)({parentName:"pre"},{className:"language-shell"}),"mysql -uroot -p db_name < backfile\n")),Object(s.b)("h2",{id:"unbuntu-1804"},"Unbuntu 18.04"),Object(s.b)("h3",{id:"prerequisites"},"Prerequisites"),Object(s.b)("p",null,"To follow this tutorial, you will need:"),Object(s.b)("p",null,"One Ubuntu 18.04 server set up by following this initial server setup guide, including a non-root user with sudo privileges and a firewall.\nStep 1 \u2014 Installing MySQL\nOn Ubuntu 18.04, only the latest version of MySQL is included in the APT package repository by default. At the time of writing, that\u2019s MySQL 5.7"),Object(s.b)("p",null,"To install it, update the package index on your server with apt:"),Object(s.b)("pre",null,Object(s.b)("code",Object(n.a)({parentName:"pre"},{className:"language-shell"}),"sudo apt update\n")),Object(s.b)("p",null,"Then install the default package:"),Object(s.b)("pre",null,Object(s.b)("code",Object(n.a)({parentName:"pre"},{className:"language-shell"}),"sudo apt install mysql-server\n")),Object(s.b)("p",null,"This will install MySQL, but will not prompt you to set a password or make any other configuration changes. Because this leaves your installation of MySQL insecure, we will address this next."),Object(s.b)("h3",{id:"step-2--configuring-mysql"},"Step 2 \u2014 Configuring MySQL"),Object(s.b)("pre",null,Object(s.b)("code",Object(n.a)({parentName:"pre"},{className:"language-shell"}),"sudo mysql_secure_installation\n")),Object(s.b)("h3",{id:"\u6388\u6743\u8bbf\u95ee"},"\u6388\u6743\u8bbf\u95ee"),Object(s.b)("p",null,Object(s.b)("strong",{parentName:"p"},"NOTE:")," root \u65e0\u6cd5\u767b\u5f55\u65f6\u4fee\u6539\u5bc6\u7801\u7684\u89e3\u51b3\u65b9\u6848"),Object(s.b)("p",null,"\u6211\u4eec\u901a\u8fc7apt-get \u547d\u4ee4\u5b89\u88c5\u7684MySQL\uff0c\u9ed8\u8ba4\u7684\u767b\u5f55\u540d\u548c\u767b\u5f55\u5bc6\u7801\u662f\u4fdd\u5b58\u5728 /etc/mysql/debian.cnf \u4e0b\u7684"),Object(s.b)("pre",null,Object(s.b)("code",Object(n.a)({parentName:"pre"},{className:"language-shell"}),"sudo cat /etc/mysql/debian.cnf\n")),Object(s.b)("ul",null,Object(s.b)("li",{parentName:"ul"},"\u4f7f\u7528 ",Object(s.b)("inlineCode",{parentName:"li"},"debian-sys-maint"),"\u767b\u5f55mysql"),Object(s.b)("li",{parentName:"ul"},"\u4fee\u6539",Object(s.b)("inlineCode",{parentName:"li"},"root"),"\u5e10\u53f7\u5bc6\u7801")),Object(s.b)("pre",null,Object(s.b)("code",Object(n.a)({parentName:"pre"},{className:"language-shell"})," use mysql\n update user set authentication_string=password(' \u4f60\u7684\u5bc6\u7801 ') where user='root' and host='localhost' \n update user set plugin=\"mysql_native_password\"\n flush privileges\n # \u91cd\u542fmysql\n sudo service mysql restart\n")),Object(s.b)("ul",null,Object(s.b)("li",{parentName:"ul"},"Check the authentication methods employed by each of your users again to confirm that root no longer authenticates using the auth_socket plugin:")),Object(s.b)("pre",null,Object(s.b)("code",Object(n.a)({parentName:"pre"},{className:"language-shell"}),"mysql> SELECT user,authentication_string,plugin,host FROM mysql.user;\n\n+------------------+-------------------------------------------+-----------------------+-----------+\n| user | authentication_string | plugin | host |\n+------------------+-------------------------------------------+-----------------------+-----------+\n| root | *3636DACC8616D997782ADD0839F92C1571D6D78F | mysql_native_password | localhost |\n| mysql.session | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |\n| mysql.sys | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |\n| debian-sys-maint | *CC744277A401A7D25BE1CA89AFF17BF607F876FF | mysql_native_password | localhost |\n+------------------+-------------------------------------------+-----------------------+-----------+\n4 rows in set (0.00 sec)\n\n")),Object(s.b)("p",null,Object(s.b)("strong",{parentName:"p"},"NOTE:")," \u786e\u8ba4root \u5e10\u53f7plugin \u4f7f\u7528\u7684\u662f",Object(s.b)("inlineCode",{parentName:"p"},"mysql_native_password"),",\u4e0d\u7136root\u5e10\u53f7\u65e0\u6cd5\u4f7f\u7528\u5bc6\u7801\u94fe\u63a5mysql, \u5982\u679c\u4e0d\u662f\u53ef\u4ee5\u5982\u4e0b\u4fee\u6539"),Object(s.b)("pre",null,Object(s.b)("code",Object(n.a)({parentName:"pre"},{className:"language-shell"}),"ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';\n")),Object(s.b)("h2",{id:"\u53c2\u8003\u8d44\u6599"},"\u53c2\u8003\u8d44\u6599"),Object(s.b)("ul",null,Object(s.b)("li",{parentName:"ul"},Object(s.b)("a",Object(n.a)({parentName:"li"},{href:"https://segmentfault.com/a/1190000003049498"}),"CentOS 6.5/6.6 \u5b89\u88c5\uff08install\uff09mysql 5.7 \u6700\u5b8c\u6574\u7248\u6559\u7a0b")),Object(s.b)("li",{parentName:"ul"},Object(s.b)("a",Object(n.a)({parentName:"li"},{href:"https://juejin.im/entry/5a0aa2026fb9a045132a369f"}),"MySQL \u5907\u4efd\u548c\u6062\u590d\u673a\u5236")),Object(s.b)("li",{parentName:"ul"},Object(s.b)("a",Object(n.a)({parentName:"li"},{href:"https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-ubuntu-18-04"}),"How To Install MySQL on Ubuntu 18.04")),Object(s.b)("li",{parentName:"ul"},Object(s.b)("a",Object(n.a)({parentName:"li"},{href:"https://blog.csdn.net/verylonglongago/article/details/85479704"}),"Ubuntu 18.04 \u7cfb\u7edf\u4e0bMySQL\u9996\u6b21\u5b89\u88c5\u7528root\u767b\u5f55\u4e0d\u4e86\uff0c\u4fee\u6539root\u521d\u59cb\u5bc6\u7801\uff0c\u89e3\u51b3\u529e\u6cd5"))))}o.isMDXComponent=!0}}]);