[{"data":1,"prerenderedAt":1027},["ShallowReactive",2],{"post-\u002Fblog\u002F2020-05-12-centos-mysql57":3,"surround-\u002Fblog\u002F2020-05-12-centos-mysql57":1020},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"tags":11,"cover":16,"source":17,"body":18,"_type":1014,"_id":1015,"_source":1016,"_file":1017,"_stem":1018,"_extension":1019},"\u002Fblog\u002F2020-05-12-centos-mysql57","blog",false,"","Centos 7.3 安装 MySQL 5.7","完整的 CentOS 7.3 安装 MySQL 5.7 教程，包括下载、安装、密码策略修改、远程访问设置及字符编码配置。","2020-05-12",[12,13,14,15],"简书","历史归档","MySQL","Linux","https:\u002F\u002Fupload-images.jianshu.io\u002Fupload_images\u002F16281566-e45bda7519cf3b87.png","https:\u002F\u002Fwww.jianshu.com\u002Fp\u002Fa4a804d978da",{"type":19,"children":20,"toc":1012},"root",[21,33,73,82,87,117,124,133,160,167,172,181,453,458,483,492,515,522,544,551,598,605,614,622,683,687,708,716,815,820,843,851,902,910,939,946,951,981,985,1006],{"type":22,"tag":23,"props":24,"children":25},"element","ol",{},[26],{"type":22,"tag":27,"props":28,"children":29},"li",{},[30],{"type":31,"value":32},"text","下载并安装MySQL官方的 Yum Repository",{"type":22,"tag":34,"props":35,"children":39},"pre",{"className":36,"code":37,"language":38,"meta":7,"style":7},"language-shell shiki shiki-themes github-light github-dark","wget -i -c http:\u002F\u002Fdev.mysql.com\u002Fget\u002Fmysql57-community-release-el7-10.noarch.rpm\n","shell",[40],{"type":22,"tag":41,"props":42,"children":43},"code",{"__ignoreMap":7},[44],{"type":22,"tag":45,"props":46,"children":49},"span",{"class":47,"line":48},"line",1,[50,56,62,67],{"type":22,"tag":45,"props":51,"children":53},{"style":52},"--shiki-default:#6F42C1;--shiki-dark:#B392F0",[54],{"type":31,"value":55},"wget",{"type":22,"tag":45,"props":57,"children":59},{"style":58},"--shiki-default:#005CC5;--shiki-dark:#79B8FF",[60],{"type":31,"value":61}," -i",{"type":22,"tag":45,"props":63,"children":64},{"style":58},[65],{"type":31,"value":66}," -c",{"type":22,"tag":45,"props":68,"children":70},{"style":69},"--shiki-default:#032F62;--shiki-dark:#9ECBFF",[71],{"type":31,"value":72}," http:\u002F\u002Fdev.mysql.com\u002Fget\u002Fmysql57-community-release-el7-10.noarch.rpm\n",{"type":22,"tag":74,"props":75,"children":76},"p",{},[77],{"type":22,"tag":78,"props":79,"children":81},"img",{"alt":7,"src":80},"https:\u002F\u002Fupload-images.jianshu.io\u002Fupload_images\u002F16281566-e45bda7519cf3b87.png?imageMogr2\u002Fauto-orient\u002Fstrip%7CimageView2\u002F2\u002Fw\u002F1200\u002Fformat\u002Fwebp",[],{"type":22,"tag":74,"props":83,"children":84},{},[85],{"type":31,"value":86},"使用上面的命令就直接下载了安装用的Yum Repository，大概25KB的样子，然后就可以直接yum安装了。",{"type":22,"tag":34,"props":88,"children":90},{"className":36,"code":89,"language":38,"meta":7,"style":7},"yum -y install mysql57-community-release-el7-10.noarch.rpm\n",[91],{"type":22,"tag":41,"props":92,"children":93},{"__ignoreMap":7},[94],{"type":22,"tag":45,"props":95,"children":96},{"class":47,"line":48},[97,102,107,112],{"type":22,"tag":45,"props":98,"children":99},{"style":52},[100],{"type":31,"value":101},"yum",{"type":22,"tag":45,"props":103,"children":104},{"style":58},[105],{"type":31,"value":106}," -y",{"type":22,"tag":45,"props":108,"children":109},{"style":69},[110],{"type":31,"value":111}," install",{"type":22,"tag":45,"props":113,"children":114},{"style":69},[115],{"type":31,"value":116}," mysql57-community-release-el7-10.noarch.rpm\n",{"type":22,"tag":74,"props":118,"children":119},{},[120],{"type":22,"tag":78,"props":121,"children":123},{"alt":7,"src":122},"https:\u002F\u002Fupload-images.jianshu.io\u002Fupload_images\u002F16281566-89ab0131d9c4ec7f.png?imageMogr2\u002Fauto-orient\u002Fstrip%7CimageView2\u002F2\u002Fw\u002F1200\u002Fformat\u002Fwebp",[],{"type":22,"tag":23,"props":125,"children":127},{"start":126},2,[128],{"type":22,"tag":27,"props":129,"children":130},{},[131],{"type":31,"value":132},"安装 MySQL 服务",{"type":22,"tag":34,"props":134,"children":136},{"className":36,"code":135,"language":38,"meta":7,"style":7},"yum -y install mysql-community-server\n",[137],{"type":22,"tag":41,"props":138,"children":139},{"__ignoreMap":7},[140],{"type":22,"tag":45,"props":141,"children":142},{"class":47,"line":48},[143,147,151,155],{"type":22,"tag":45,"props":144,"children":145},{"style":52},[146],{"type":31,"value":101},{"type":22,"tag":45,"props":148,"children":149},{"style":58},[150],{"type":31,"value":106},{"type":22,"tag":45,"props":152,"children":153},{"style":69},[154],{"type":31,"value":111},{"type":22,"tag":45,"props":156,"children":157},{"style":69},[158],{"type":31,"value":159}," mysql-community-server\n",{"type":22,"tag":74,"props":161,"children":162},{},[163],{"type":22,"tag":78,"props":164,"children":166},{"alt":7,"src":165},"https:\u002F\u002Fupload-images.jianshu.io\u002Fupload_images\u002F16281566-4f1347bae5c9905a.png?imageMogr2\u002Fauto-orient\u002Fstrip%7CimageView2\u002F2\u002Fw\u002F1200\u002Fformat\u002Fwebp",[],{"type":22,"tag":74,"props":168,"children":169},{},[170],{"type":31,"value":171},"这个过程比较漫长.....",{"type":22,"tag":23,"props":173,"children":175},{"start":174},3,[176],{"type":22,"tag":27,"props":177,"children":178},{},[179],{"type":31,"value":180},"MySQL 配置",{"type":22,"tag":34,"props":182,"children":186},{"className":183,"code":184,"language":185,"meta":7,"style":7},"language-ini shiki shiki-themes github-light github-dark","# For advice on how to change settings please see\n# http:\u002F\u002Fdev.mysql.com\u002Fdoc\u002Frefman\u002F5.7\u002Fen\u002Fserver-configuration-defaults.html\n\n[mysqld]\n#\n# Remove leading # and set to the amount of RAM for the most important data\n# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.\n# innodb_buffer_pool_size = 128M\n#\n# Remove leading # to turn on a very important data integrity option: logging\n# changes to the binary log between backups.\n# log_bin\n#\n# Remove leading # to set options mainly useful for reporting servers.\n# The server defaults are faster for transactions and fast SELECTs.\n# Adjust sizes as needed, experiment to find the optimal values.\n# join_buffer_size = 128M\n# sort_buffer_size = 2M\n# read_rnd_buffer_size = 2M\ndatadir=\u002Fvar\u002Flib\u002Fmysql\nsocket=\u002Fvar\u002Flib\u002Fmysql\u002Fmysql.sock\n\n# 绑定 ip\nbind-address=0.0.0.0\n\n# Disabling symbolic-links is recommended to prevent assorted security risks\nsymbolic-links=0\n\nlog-error=\u002Fvar\u002Flog\u002Fmysqld.log\npid-file=\u002Fvar\u002Frun\u002Fmysqld\u002Fmysqld.pid\n","ini",[187],{"type":22,"tag":41,"props":188,"children":189},{"__ignoreMap":7},[190,198,206,215,224,233,242,251,260,268,277,286,295,303,312,321,330,339,348,357,366,375,383,392,401,409,418,427,435,444],{"type":22,"tag":45,"props":191,"children":192},{"class":47,"line":48},[193],{"type":22,"tag":45,"props":194,"children":195},{},[196],{"type":31,"value":197},"# For advice on how to change settings please see\n",{"type":22,"tag":45,"props":199,"children":200},{"class":47,"line":126},[201],{"type":22,"tag":45,"props":202,"children":203},{},[204],{"type":31,"value":205},"# http:\u002F\u002Fdev.mysql.com\u002Fdoc\u002Frefman\u002F5.7\u002Fen\u002Fserver-configuration-defaults.html\n",{"type":22,"tag":45,"props":207,"children":208},{"class":47,"line":174},[209],{"type":22,"tag":45,"props":210,"children":212},{"emptyLinePlaceholder":211},true,[213],{"type":31,"value":214},"\n",{"type":22,"tag":45,"props":216,"children":218},{"class":47,"line":217},4,[219],{"type":22,"tag":45,"props":220,"children":221},{},[222],{"type":31,"value":223},"[mysqld]\n",{"type":22,"tag":45,"props":225,"children":227},{"class":47,"line":226},5,[228],{"type":22,"tag":45,"props":229,"children":230},{},[231],{"type":31,"value":232},"#\n",{"type":22,"tag":45,"props":234,"children":236},{"class":47,"line":235},6,[237],{"type":22,"tag":45,"props":238,"children":239},{},[240],{"type":31,"value":241},"# Remove leading # and set to the amount of RAM for the most important data\n",{"type":22,"tag":45,"props":243,"children":245},{"class":47,"line":244},7,[246],{"type":22,"tag":45,"props":247,"children":248},{},[249],{"type":31,"value":250},"# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.\n",{"type":22,"tag":45,"props":252,"children":254},{"class":47,"line":253},8,[255],{"type":22,"tag":45,"props":256,"children":257},{},[258],{"type":31,"value":259},"# innodb_buffer_pool_size = 128M\n",{"type":22,"tag":45,"props":261,"children":263},{"class":47,"line":262},9,[264],{"type":22,"tag":45,"props":265,"children":266},{},[267],{"type":31,"value":232},{"type":22,"tag":45,"props":269,"children":271},{"class":47,"line":270},10,[272],{"type":22,"tag":45,"props":273,"children":274},{},[275],{"type":31,"value":276},"# Remove leading # to turn on a very important data integrity option: logging\n",{"type":22,"tag":45,"props":278,"children":280},{"class":47,"line":279},11,[281],{"type":22,"tag":45,"props":282,"children":283},{},[284],{"type":31,"value":285},"# changes to the binary log between backups.\n",{"type":22,"tag":45,"props":287,"children":289},{"class":47,"line":288},12,[290],{"type":22,"tag":45,"props":291,"children":292},{},[293],{"type":31,"value":294},"# log_bin\n",{"type":22,"tag":45,"props":296,"children":298},{"class":47,"line":297},13,[299],{"type":22,"tag":45,"props":300,"children":301},{},[302],{"type":31,"value":232},{"type":22,"tag":45,"props":304,"children":306},{"class":47,"line":305},14,[307],{"type":22,"tag":45,"props":308,"children":309},{},[310],{"type":31,"value":311},"# Remove leading # to set options mainly useful for reporting servers.\n",{"type":22,"tag":45,"props":313,"children":315},{"class":47,"line":314},15,[316],{"type":22,"tag":45,"props":317,"children":318},{},[319],{"type":31,"value":320},"# The server defaults are faster for transactions and fast SELECTs.\n",{"type":22,"tag":45,"props":322,"children":324},{"class":47,"line":323},16,[325],{"type":22,"tag":45,"props":326,"children":327},{},[328],{"type":31,"value":329},"# Adjust sizes as needed, experiment to find the optimal values.\n",{"type":22,"tag":45,"props":331,"children":333},{"class":47,"line":332},17,[334],{"type":22,"tag":45,"props":335,"children":336},{},[337],{"type":31,"value":338},"# join_buffer_size = 128M\n",{"type":22,"tag":45,"props":340,"children":342},{"class":47,"line":341},18,[343],{"type":22,"tag":45,"props":344,"children":345},{},[346],{"type":31,"value":347},"# sort_buffer_size = 2M\n",{"type":22,"tag":45,"props":349,"children":351},{"class":47,"line":350},19,[352],{"type":22,"tag":45,"props":353,"children":354},{},[355],{"type":31,"value":356},"# read_rnd_buffer_size = 2M\n",{"type":22,"tag":45,"props":358,"children":360},{"class":47,"line":359},20,[361],{"type":22,"tag":45,"props":362,"children":363},{},[364],{"type":31,"value":365},"datadir=\u002Fvar\u002Flib\u002Fmysql\n",{"type":22,"tag":45,"props":367,"children":369},{"class":47,"line":368},21,[370],{"type":22,"tag":45,"props":371,"children":372},{},[373],{"type":31,"value":374},"socket=\u002Fvar\u002Flib\u002Fmysql\u002Fmysql.sock\n",{"type":22,"tag":45,"props":376,"children":378},{"class":47,"line":377},22,[379],{"type":22,"tag":45,"props":380,"children":381},{"emptyLinePlaceholder":211},[382],{"type":31,"value":214},{"type":22,"tag":45,"props":384,"children":386},{"class":47,"line":385},23,[387],{"type":22,"tag":45,"props":388,"children":389},{},[390],{"type":31,"value":391},"# 绑定 ip\n",{"type":22,"tag":45,"props":393,"children":395},{"class":47,"line":394},24,[396],{"type":22,"tag":45,"props":397,"children":398},{},[399],{"type":31,"value":400},"bind-address=0.0.0.0\n",{"type":22,"tag":45,"props":402,"children":404},{"class":47,"line":403},25,[405],{"type":22,"tag":45,"props":406,"children":407},{"emptyLinePlaceholder":211},[408],{"type":31,"value":214},{"type":22,"tag":45,"props":410,"children":412},{"class":47,"line":411},26,[413],{"type":22,"tag":45,"props":414,"children":415},{},[416],{"type":31,"value":417},"# Disabling symbolic-links is recommended to prevent assorted security risks\n",{"type":22,"tag":45,"props":419,"children":421},{"class":47,"line":420},27,[422],{"type":22,"tag":45,"props":423,"children":424},{},[425],{"type":31,"value":426},"symbolic-links=0\n",{"type":22,"tag":45,"props":428,"children":430},{"class":47,"line":429},28,[431],{"type":22,"tag":45,"props":432,"children":433},{"emptyLinePlaceholder":211},[434],{"type":31,"value":214},{"type":22,"tag":45,"props":436,"children":438},{"class":47,"line":437},29,[439],{"type":22,"tag":45,"props":440,"children":441},{},[442],{"type":31,"value":443},"log-error=\u002Fvar\u002Flog\u002Fmysqld.log\n",{"type":22,"tag":45,"props":445,"children":447},{"class":47,"line":446},30,[448],{"type":22,"tag":45,"props":449,"children":450},{},[451],{"type":31,"value":452},"pid-file=\u002Fvar\u002Frun\u002Fmysqld\u002Fmysqld.pid\n",{"type":22,"tag":74,"props":454,"children":455},{},[456],{"type":31,"value":457},"重启mysql服务使配置生效",{"type":22,"tag":34,"props":459,"children":461},{"className":36,"code":460,"language":38,"meta":7,"style":7},"systemctl restart mysqld\n",[462],{"type":22,"tag":41,"props":463,"children":464},{"__ignoreMap":7},[465],{"type":22,"tag":45,"props":466,"children":467},{"class":47,"line":48},[468,473,478],{"type":22,"tag":45,"props":469,"children":470},{"style":52},[471],{"type":31,"value":472},"systemctl",{"type":22,"tag":45,"props":474,"children":475},{"style":69},[476],{"type":31,"value":477}," restart",{"type":22,"tag":45,"props":479,"children":480},{"style":69},[481],{"type":31,"value":482}," mysqld\n",{"type":22,"tag":484,"props":485,"children":486},"ul",{},[487],{"type":22,"tag":27,"props":488,"children":489},{},[490],{"type":31,"value":491},"查看 MySQL 运行状态，运行状态如图：",{"type":22,"tag":34,"props":493,"children":495},{"className":36,"code":494,"language":38,"meta":7,"style":7},"systemctl status mysqld\n",[496],{"type":22,"tag":41,"props":497,"children":498},{"__ignoreMap":7},[499],{"type":22,"tag":45,"props":500,"children":501},{"class":47,"line":48},[502,506,511],{"type":22,"tag":45,"props":503,"children":504},{"style":52},[505],{"type":31,"value":472},{"type":22,"tag":45,"props":507,"children":508},{"style":69},[509],{"type":31,"value":510}," status",{"type":22,"tag":45,"props":512,"children":513},{"style":69},[514],{"type":31,"value":482},{"type":22,"tag":74,"props":516,"children":517},{},[518],{"type":22,"tag":78,"props":519,"children":521},{"alt":7,"src":520},"https:\u002F\u002Fupload-images.jianshu.io\u002Fupload_images\u002F16281566-eff41e1a4f7dd170.png?imageMogr2\u002Fauto-orient\u002Fstrip%7CimageView2\u002F2\u002Fw\u002F1200\u002Fformat\u002Fwebp",[],{"type":22,"tag":484,"props":523,"children":524},{},[525],{"type":22,"tag":27,"props":526,"children":527},{},[528,530,536,538],{"type":31,"value":529},"查看 ",{"type":22,"tag":41,"props":531,"children":533},{"className":532},[],[534],{"type":31,"value":535},"root@localhost",{"type":31,"value":537}," 密码, ",{"type":22,"tag":41,"props":539,"children":541},{"className":540},[],[542],{"type":31,"value":543},"grep \"password\" \u002Fvar\u002Flog\u002Fmysqld.log",{"type":22,"tag":74,"props":545,"children":546},{},[547],{"type":22,"tag":78,"props":548,"children":550},{"alt":7,"src":549},"https:\u002F\u002Fupload-images.jianshu.io\u002Fupload_images\u002F16281566-ca5f7369dd316da1.png?imageMogr2\u002Fauto-orient\u002Fstrip%7CimageView2\u002F2\u002Fw\u002F1100\u002Fformat\u002Fwebp",[],{"type":22,"tag":484,"props":552,"children":553},{},[554,567,587],{"type":22,"tag":27,"props":555,"children":556},{},[557,559,565],{"type":31,"value":558},"进入数据库 ",{"type":22,"tag":41,"props":560,"children":562},{"className":561},[],[563],{"type":31,"value":564},"mysql -u root -p",{"type":31,"value":566}," ，输入初始密码",{"type":22,"tag":27,"props":568,"children":569},{},[570,572,577,579,585],{"type":31,"value":571},"修改 ",{"type":22,"tag":41,"props":573,"children":575},{"className":574},[],[576],{"type":31,"value":535},{"type":31,"value":578}," 密码， ",{"type":22,"tag":41,"props":580,"children":582},{"className":581},[],[583],{"type":31,"value":584},"ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';",{"type":31,"value":586},"\n其中'new password'替换成你要设置的密码，注意:密码设置必须要大小写字母数字和特殊符号（,\u002F';:等）,不然不能配置成功，如果要修改为root这样的弱密码，需要进行以下配置：",{"type":22,"tag":27,"props":588,"children":589},{},[590,592],{"type":31,"value":591},"查看当前密码策略 ",{"type":22,"tag":41,"props":593,"children":595},{"className":594},[],[596],{"type":31,"value":597},"show variables like '%password%';",{"type":22,"tag":74,"props":599,"children":600},{},[601],{"type":22,"tag":78,"props":602,"children":604},{"alt":7,"src":603},"https:\u002F\u002Fupload-images.jianshu.io\u002Fupload_images\u002F16281566-eee308db62b5f3c8.png?imageMogr2\u002Fauto-orient\u002Fstrip%7CimageView2\u002F2\u002Fw\u002F1021\u002Fformat\u002Fwebp",[],{"type":22,"tag":606,"props":607,"children":608},"blockquote",{},[609],{"type":22,"tag":74,"props":610,"children":611},{},[612],{"type":31,"value":613},"策略说明\nvalidate_password.length 是密码的最小长度，默认是8，我们把它改成6\n输入：set global validate_password.length=6;\nvalidate_password.policy 验证密码的复杂程度，我们把它改成0\n输入：set global validate_password.policy=0;\nvalidate_password.check_user_name 用户名检查，用户名和密码不能相同，我们也把它关掉\n输入：set global validate_password.check_user_name=off;",{"type":22,"tag":484,"props":615,"children":616},{},[617],{"type":22,"tag":27,"props":618,"children":619},{},[620],{"type":31,"value":621},"修改密码策略\n添加validate_password_policy配置\n选择0（LOW），1（MEDIUM），2（STRONG）其中一种，选择2需要提供密码字典文件",{"type":22,"tag":34,"props":623,"children":625},{"className":183,"code":624,"language":185,"meta":7,"style":7},"[mysqld]\n# ...省略其他配置...\n\n# 添加validate_password_policy配置\nvalidate_password_policy=0\n# 关闭密码策略\nvalidate_password = off\n",[626],{"type":22,"tag":41,"props":627,"children":628},{"__ignoreMap":7},[629,636,644,651,659,667,675],{"type":22,"tag":45,"props":630,"children":631},{"class":47,"line":48},[632],{"type":22,"tag":45,"props":633,"children":634},{},[635],{"type":31,"value":223},{"type":22,"tag":45,"props":637,"children":638},{"class":47,"line":126},[639],{"type":22,"tag":45,"props":640,"children":641},{},[642],{"type":31,"value":643},"# ...省略其他配置...\n",{"type":22,"tag":45,"props":645,"children":646},{"class":47,"line":174},[647],{"type":22,"tag":45,"props":648,"children":649},{"emptyLinePlaceholder":211},[650],{"type":31,"value":214},{"type":22,"tag":45,"props":652,"children":653},{"class":47,"line":217},[654],{"type":22,"tag":45,"props":655,"children":656},{},[657],{"type":31,"value":658},"# 添加validate_password_policy配置\n",{"type":22,"tag":45,"props":660,"children":661},{"class":47,"line":226},[662],{"type":22,"tag":45,"props":663,"children":664},{},[665],{"type":31,"value":666},"validate_password_policy=0\n",{"type":22,"tag":45,"props":668,"children":669},{"class":47,"line":235},[670],{"type":22,"tag":45,"props":671,"children":672},{},[673],{"type":31,"value":674},"# 关闭密码策略\n",{"type":22,"tag":45,"props":676,"children":677},{"class":47,"line":244},[678],{"type":22,"tag":45,"props":679,"children":680},{},[681],{"type":31,"value":682},"validate_password = off\n",{"type":22,"tag":74,"props":684,"children":685},{},[686],{"type":31,"value":457},{"type":22,"tag":34,"props":688,"children":689},{"className":36,"code":460,"language":38,"meta":7,"style":7},[690],{"type":22,"tag":41,"props":691,"children":692},{"__ignoreMap":7},[693],{"type":22,"tag":45,"props":694,"children":695},{"class":47,"line":48},[696,700,704],{"type":22,"tag":45,"props":697,"children":698},{"style":52},[699],{"type":31,"value":472},{"type":22,"tag":45,"props":701,"children":702},{"style":69},[703],{"type":31,"value":477},{"type":22,"tag":45,"props":705,"children":706},{"style":69},[707],{"type":31,"value":482},{"type":22,"tag":23,"props":709,"children":710},{"start":217},[711],{"type":22,"tag":27,"props":712,"children":713},{},[714],{"type":31,"value":715},"开启mysql的远程访问\n执行以下命令开启远程访问限制（注意：下面命令开启的IP是 192.168.0.1，如要开启所有的，用%代替IP）：",{"type":22,"tag":34,"props":717,"children":721},{"className":718,"code":719,"language":720,"meta":7,"style":7},"language-sql shiki shiki-themes github-light github-dark","grant all privileges on *.* to 'root'@'192.168.0.1' identified by 'password' with grant option;\n","sql",[722],{"type":22,"tag":41,"props":723,"children":724},{"__ignoreMap":7},[725],{"type":22,"tag":45,"props":726,"children":727},{"class":47,"line":48},[728,734,740,745,750,755,760,765,770,775,780,785,790,795,800,805,810],{"type":22,"tag":45,"props":729,"children":731},{"style":730},"--shiki-default:#D73A49;--shiki-dark:#F97583",[732],{"type":31,"value":733},"grant",{"type":22,"tag":45,"props":735,"children":737},{"style":736},"--shiki-default:#24292E;--shiki-dark:#E1E4E8",[738],{"type":31,"value":739}," all privileges ",{"type":22,"tag":45,"props":741,"children":742},{"style":730},[743],{"type":31,"value":744},"on",{"type":22,"tag":45,"props":746,"children":747},{"style":730},[748],{"type":31,"value":749}," *",{"type":22,"tag":45,"props":751,"children":752},{"style":736},[753],{"type":31,"value":754},".",{"type":22,"tag":45,"props":756,"children":757},{"style":730},[758],{"type":31,"value":759},"*",{"type":22,"tag":45,"props":761,"children":762},{"style":730},[763],{"type":31,"value":764}," to",{"type":22,"tag":45,"props":766,"children":767},{"style":69},[768],{"type":31,"value":769}," 'root'",{"type":22,"tag":45,"props":771,"children":772},{"style":736},[773],{"type":31,"value":774},"@",{"type":22,"tag":45,"props":776,"children":777},{"style":69},[778],{"type":31,"value":779},"'192.168.0.1'",{"type":22,"tag":45,"props":781,"children":782},{"style":736},[783],{"type":31,"value":784}," identified ",{"type":22,"tag":45,"props":786,"children":787},{"style":730},[788],{"type":31,"value":789},"by",{"type":22,"tag":45,"props":791,"children":792},{"style":69},[793],{"type":31,"value":794}," 'password'",{"type":22,"tag":45,"props":796,"children":797},{"style":730},[798],{"type":31,"value":799}," with",{"type":22,"tag":45,"props":801,"children":802},{"style":730},[803],{"type":31,"value":804}," grant",{"type":22,"tag":45,"props":806,"children":807},{"style":730},[808],{"type":31,"value":809}," option",{"type":22,"tag":45,"props":811,"children":812},{"style":736},[813],{"type":31,"value":814},";\n",{"type":22,"tag":74,"props":816,"children":817},{},[818],{"type":31,"value":819},"然后再输入下面两行命令",{"type":22,"tag":34,"props":821,"children":823},{"className":718,"code":822,"language":720,"meta":7,"style":7},"flush privileges;\nexit;\n",[824],{"type":22,"tag":41,"props":825,"children":826},{"__ignoreMap":7},[827,835],{"type":22,"tag":45,"props":828,"children":829},{"class":47,"line":48},[830],{"type":22,"tag":45,"props":831,"children":832},{"style":736},[833],{"type":31,"value":834},"flush privileges;\n",{"type":22,"tag":45,"props":836,"children":837},{"class":47,"line":126},[838],{"type":22,"tag":45,"props":839,"children":840},{"style":736},[841],{"type":31,"value":842},"exit;\n",{"type":22,"tag":23,"props":844,"children":845},{"start":226},[846],{"type":22,"tag":27,"props":847,"children":848},{},[849],{"type":31,"value":850},"为 firewalld 添加开放端口\n添加mysql端口3306",{"type":22,"tag":34,"props":852,"children":854},{"className":36,"code":853,"language":38,"meta":7,"style":7},"firewall-cmd --zone=public --add-port=3306\u002Ftcp --permanent\n# 重新加载\nfirewall-cmd --reload\n",[855],{"type":22,"tag":41,"props":856,"children":857},{"__ignoreMap":7},[858,881,890],{"type":22,"tag":45,"props":859,"children":860},{"class":47,"line":48},[861,866,871,876],{"type":22,"tag":45,"props":862,"children":863},{"style":52},[864],{"type":31,"value":865},"firewall-cmd",{"type":22,"tag":45,"props":867,"children":868},{"style":58},[869],{"type":31,"value":870}," --zone=public",{"type":22,"tag":45,"props":872,"children":873},{"style":58},[874],{"type":31,"value":875}," --add-port=3306\u002Ftcp",{"type":22,"tag":45,"props":877,"children":878},{"style":58},[879],{"type":31,"value":880}," --permanent\n",{"type":22,"tag":45,"props":882,"children":883},{"class":47,"line":126},[884],{"type":22,"tag":45,"props":885,"children":887},{"style":886},"--shiki-default:#6A737D;--shiki-dark:#6A737D",[888],{"type":31,"value":889},"# 重新加载\n",{"type":22,"tag":45,"props":891,"children":892},{"class":47,"line":174},[893,897],{"type":22,"tag":45,"props":894,"children":895},{"style":52},[896],{"type":31,"value":865},{"type":22,"tag":45,"props":898,"children":899},{"style":58},[900],{"type":31,"value":901}," --reload\n",{"type":22,"tag":23,"props":903,"children":904},{"start":235},[905],{"type":22,"tag":27,"props":906,"children":907},{},[908],{"type":31,"value":909},"修改mysql的字符编码（不修改会产生中文乱码问题）\n显示原来编码：",{"type":22,"tag":34,"props":911,"children":913},{"className":718,"code":912,"language":720,"meta":7,"style":7},"show variables like '%character%';\n",[914],{"type":22,"tag":41,"props":915,"children":916},{"__ignoreMap":7},[917],{"type":22,"tag":45,"props":918,"children":919},{"class":47,"line":48},[920,925,930,935],{"type":22,"tag":45,"props":921,"children":922},{"style":736},[923],{"type":31,"value":924},"show variables ",{"type":22,"tag":45,"props":926,"children":927},{"style":730},[928],{"type":31,"value":929},"like",{"type":22,"tag":45,"props":931,"children":932},{"style":69},[933],{"type":31,"value":934}," '%character%'",{"type":22,"tag":45,"props":936,"children":937},{"style":736},[938],{"type":31,"value":814},{"type":22,"tag":74,"props":940,"children":941},{},[942],{"type":22,"tag":78,"props":943,"children":945},{"alt":7,"src":944},"https:\u002F\u002Fupload-images.jianshu.io\u002Fupload_images\u002F16281566-d8183a07edf14f58.png?imageMogr2\u002Fauto-orient\u002Fstrip%7CimageView2\u002F2\u002Fw\u002F932\u002Fformat\u002Fwebp",[],{"type":22,"tag":74,"props":947,"children":948},{},[949],{"type":31,"value":950},"修改\u002Fetc\u002Fmy.cnf",{"type":22,"tag":34,"props":952,"children":954},{"className":183,"code":953,"language":185,"meta":7,"style":7},"[mysqld]\ncharacter_set_server=utf8\ninit_connect='SET NAMES utf8'\n",[955],{"type":22,"tag":41,"props":956,"children":957},{"__ignoreMap":7},[958,965,973],{"type":22,"tag":45,"props":959,"children":960},{"class":47,"line":48},[961],{"type":22,"tag":45,"props":962,"children":963},{},[964],{"type":31,"value":223},{"type":22,"tag":45,"props":966,"children":967},{"class":47,"line":126},[968],{"type":22,"tag":45,"props":969,"children":970},{},[971],{"type":31,"value":972},"character_set_server=utf8\n",{"type":22,"tag":45,"props":974,"children":975},{"class":47,"line":174},[976],{"type":22,"tag":45,"props":977,"children":978},{},[979],{"type":31,"value":980},"init_connect='SET NAMES utf8'\n",{"type":22,"tag":74,"props":982,"children":983},{},[984],{"type":31,"value":457},{"type":22,"tag":34,"props":986,"children":987},{"className":36,"code":460,"language":38,"meta":7,"style":7},[988],{"type":22,"tag":41,"props":989,"children":990},{"__ignoreMap":7},[991],{"type":22,"tag":45,"props":992,"children":993},{"class":47,"line":48},[994,998,1002],{"type":22,"tag":45,"props":995,"children":996},{"style":52},[997],{"type":31,"value":472},{"type":22,"tag":45,"props":999,"children":1000},{"style":69},[1001],{"type":31,"value":477},{"type":22,"tag":45,"props":1003,"children":1004},{"style":69},[1005],{"type":31,"value":482},{"type":22,"tag":1007,"props":1008,"children":1009},"style",{},[1010],{"type":31,"value":1011},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":7,"searchDepth":174,"depth":174,"links":1013},[],"markdown","content:blog:2020-05-12-centos-mysql57.md","content","blog\u002F2020-05-12-centos-mysql57.md","blog\u002F2020-05-12-centos-mysql57","md",[1021,1024],{"_path":1022,"title":1023},"\u002Fblog\u002F2020-05-12-canal-kafka-mysql","Canal + Kafka 实现 MySQL 的 binlog 近实时同步",{"_path":1025,"title":1026},"\u002Fblog\u002F2020-05-12-centos-mysql80","Centos 7.3 安装 MySQL 8.0",1796523532993]