CentOS7.8安装mysql 8.0.20的教程详解
一、安装mysql软件
下载并安装MySQL官方的 YumRepository,Mysql版本8.0.20
wget-i-c http://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
下载后直接yum安装
yum-yinstallmysql80-community-release-el7-3.noarch.rpm
安装MySQL服务器
yum-yinstallmysql-community-server
[root@CentOSLinux]#yum-yinstallmysql-community-server Loadedplugins:fastestmirror,langpacks Loadingmirrorspeedsfromcachedhostfile *base:mirror.lzu.edu.cn *extras:mirror.lzu.edu.cn *updates:mirror.lzu.edu.cn mysql-connectors-community|2.5kB00:00:00 mysql-tools-community|2.5kB00:00:00 mysql80-community|2.5kB00:00:00 (1/3):mysql-connectors-community/x86_64/primary_db|57kB00:00:00 mysql-tools-community/x86_64/pFAILEDB00:51:07ETA http://repo.mysql.com/yum/mysql-tools-community/el/7/x86_64/repodata/12bd1e8730cd532791529877bf5e7babbbb02879-primary.sqlite.bz2:[Errno12]Timeoutonhttp://repo.mysql.com/yum/mysql-tools-community/el/7/x86_64/repodata/12bd1e8730cd532791529877bf5e7babbbb02879-primary.sqlite.bz2:(28,'Operationtooslow.Lessthan1000bytes/sectransferredthelast30seconds') Tryingothermirror. (2/3):mysql-tools-community/x86_64/primary_db|72kB00:00:00 mysql80-community/x86_64/primaFAILEDB00:00:15ETA http://repo.mysql.com/yum/mysql-8.0-community/el/7/x86_64/repodata/833c637b3989c2dd5a079a045177d2f1c96e9c1e-primary.sqlite.bz2:[Errno12]Timeoutonhttp://repo.mysql.com/yum/mysql-8.0-community/el/7/x86_64/repodata/833c637b3989c2dd5a079a045177d2f1c96e9c1e-primary.sqlite.bz2:(28,'Operationtooslow.Lessthan1000bytes/sectransferredthelast30seconds') Tryingothermirror. (3/3):mysql80-community/x86_64/primary_db|107kB00:00:00 ResolvingDependencies -->Runningtransactioncheck --->Packagemysql-community-server.x86_640:8.0.20-1.el7willbeinstalled -->ProcessingDependency:mysql-community-common(x86-64)=8.0.20-1.el7forpackage:mysql-community-server-8.0.20-1.el7.x86_64 -->ProcessingDependency:mysql-community-client(x86-64)>=8.0.11forpackage:mysql-community-server-8.0.20-1.el7.x86_64 -->Runningtransactioncheck --->Packagemysql-community-client.x86_640:8.0.20-1.el7willbeinstalled -->ProcessingDependency:mysql-community-libs(x86-64)>=8.0.11forpackage:mysql-community-client-8.0.20-1.el7.x86_64 --->Packagemysql-community-common.x86_640:8.0.20-1.el7willbeinstalled -->Runningtransactioncheck --->Packagemariadb-libs.x86_641:5.5.65-1.el7willbeobsoleted -->ProcessingDependency:libmysqlclient.so.18()(64bit)forpackage:2:postfix-2.10.1-9.el7.x86_64 -->ProcessingDependency:libmysqlclient.so.18(libmysqlclient_18)(64bit)forpackage:2:postfix-2.10.1-9.el7.x86_64 --->Packagemysql-community-libs.x86_640:8.0.20-1.el7willbeobsoleting -->Runningtransactioncheck --->Packagemysql-community-libs-compat.x86_640:8.0.20-1.el7willbeobsoleting -->FinishedDependencyResolution DependenciesResolved =============================================================================================== PackageArchVersionRepositorySize =============================================================================================== Installing: mysql-community-libsx86_648.0.20-1.el7mysql80-community4.5M replacingmariadb-libs.x86_641:5.5.65-1.el7 mysql-community-libs-compatx86_648.0.20-1.el7mysql80-community1.2M replacingmariadb-libs.x86_641:5.5.65-1.el7 mysql-community-serverx86_648.0.20-1.el7mysql80-community488M Installingfordependencies: mysql-community-clientx86_648.0.20-1.el7mysql80-community47M mysql-community-commonx86_648.0.20-1.el7mysql80-community609k TransactionSummary =============================================================================================== Install3Packages(+2Dependentpackages) Totaldownloadsize:541M Isthisok[y/d/N]:y Downloadingpackages: warning:/var/cache/yum/x86_64/7/mysql80-community/packages/mysql-community-common-8.0.20-1.el7.x86_64.rpm:HeaderV3DSA/SHA1Signature,keyID5072e1f5:NOKEY Publickeyformysql-community-common-8.0.20-1.el7.x86_64.rpmisnotinstalled (1/5):mysql-community-common-8.0.20-1.el7.x86_64.rpm|609kB00:00:00 (2/5):mysql-community-libs-8.0.20-1.el7.x86_64.rpm|4.5MB00:00:13 (3/5):mysql-community-libs-compat-8.0.20-1.el7.x86_64.rpm|1.2MB00:00:04 mysql-community-client-8.0.20-FAILEDB00:22:23ETA http://repo.mysql.com/yum/mysql-8.0-community/el/7/x86_64/mysql-community-client-8.0.20-1.el7.x86_64.rpm:[Errno12]Timeoutonhttp://repo.mysql.com/yum/mysql-8.0-community/el/7/x86_64/mysql-community-client-8.0.20-1.el7.x86_64.rpm:(28,'Operationtooslow.Lessthan1000bytes/sectransferredthelast30seconds') Tryingothermirror. (4/5):mysql-community-server-8.0.20-1.el7.x86_64.rpm|488MB00:22:18 (5/5):mysql-community-client-8.0.20-1.el7.x86_64.rpm|47MB00:01:57 ----------------------------------------------------------------------------------------------- Total376kB/s|541MB00:24:34 Retrievingkeyfromfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql ImportingGPGkey0x5072E1F5: Userid:"MySQLReleaseEngineering" Fingerprint:a4a9406876fcbd3c456770c88c718d3b5072e1f5 Package:mysql80-community-release-el7-3.noarch(installed) From:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql Isthisok[y/N]:y Runningtransactioncheck Runningtransactiontest Transactiontestsucceeded Runningtransaction Warning:RPMDBalteredoutsideofyum. Installing:mysql-community-common-8.0.20-1.el7.x86_641/6 Installing:mysql-community-libs-8.0.20-1.el7.x86_642/6 Installing:mysql-community-client-8.0.20-1.el7.x86_643/6 Installing:mysql-community-server-8.0.20-1.el7.x86_644/6 Installing:mysql-community-libs-compat-8.0.20-1.el7.x86_645/6 Erasing:1:mariadb-libs-5.5.65-1.el7.x86_646/6 Verifying:mysql-community-libs-compat-8.0.20-1.el7.x86_641/6 Verifying:mysql-community-common-8.0.20-1.el7.x86_642/6 Verifying:mysql-community-server-8.0.20-1.el7.x86_643/6 Verifying:mysql-community-client-8.0.20-1.el7.x86_644/6 Verifying:mysql-community-libs-8.0.20-1.el7.x86_645/6 Verifying:1:mariadb-libs-5.5.65-1.el7.x86_646/6 Installed: mysql-community-libs.x86_640:8.0.20-1.el7 mysql-community-libs-compat.x86_640:8.0.20-1.el7 mysql-community-server.x86_640:8.0.20-1.el7 DependencyInstalled: mysql-community-client.x86_640:8.0.20-1.el7mysql-community-common.x86_640:8.0.20-1.el7 Replaced: mariadb-libs.x86_641:5.5.65-1.el7 Complete!
安装完成后就会覆盖掉之前的mariadb
二、配置Mysql数据库
启动MySQL
systemctlstartmysqld.service
查看MySQL运行状态
systemctlstatusmysqld.service
●mysqld.service-MySQLServer Loaded:loaded(/usr/lib/systemd/system/mysqld.service;enabled;vendorpreset:disabled) Active:active(running)sinceWed2020-05-1323:57:41HKT;18sago Docs:man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html Process:9563ExecStartPre=/usr/bin/mysqld_pre_systemd(code=exited,status=0/SUCCESS) MainPID:9649(mysqld) Status:"Serverisoperational" Tasks:39 CGroup:/system.slice/mysqld.service └─9649/usr/sbin/mysqld May1323:57:34CentOS.highning.comsystemd[1]:StartingMySQLServer... May1323:57:41CentOS.highning.comsystemd[1]:StartedMySQLServer.
找出root初始密码
grep"password"/var/log/mysqld.log
2020-05-13T15:57:37.815353Z6[Note][MY-010454][Server]Atemporarypasswordisgeneratedforroot@localhost:9*CxxNRWHqmL
进入数据库:
mysql-uroot-p
输入密码(密码是上面查询到的,/wsw6gif;eH),此时不能操作数据库,必须修改密码之后才能操作数据库
ALTERUSER'root'@'localhost'IDENTIFIEDBY'newpassword';
其中‘newpassword'替换成你要设置的密码,注意:密码设置必须要大小写字母数字和特殊符号(,/';:等),不然不能配置成功
三、开启mysql的远程访问
执行以下命令开启远程访问限制(注意:下面命令开启的IP是192.168.0.1,如要开启所有的,用%代替IP),mysql8.0和以前的版本不一样,不能用原来的命令同时授权和创建用户:
createuser'root'@'192.168.0.1'identifiedby'password'; grantallprivilegeson*.*to'root'@'192.168.0.1'withgrantoption;
再输入以下两行命令
flushprivileges; exit
四、为firewalld添加开放端口
添加mysql端口3306和Tomcat端口8080
firewall-cmd--zone=public--add-port=3306/tcp--permanent firewall-cmd--zone=public--add-port=8080/tcp--permanent
重新载入
firewall-cmd--reload
最后在windows下用mysql命令登录
MicrosoftWindows[版本10.0.18363.778] (c)2019MicrosoftCorporation。保留所有权利。 C:\Users\highning>mysql-h192.168.88.88-P3306-uroot-p Enterpassword:******** WelcometotheMySQLmonitor.Commandsendwith;or\g. YourMySQLconnectionidis10 Serverversion:8.0.20MySQLCommunityServer-GPL Copyright(c)2000,2020,Oracleand/oritsaffiliates.Allrightsreserved. OracleisaregisteredtrademarkofOracleCorporationand/orits affiliates.Othernamesmaybetrademarksoftheirrespective owners. Type'help;'or'\h'forhelp.Type'\c'toclearthecurrentinputstatement. mysql>showdatabases; +--------------------+ |Database| +--------------------+ |information_schema| |mysql| |performance_schema| |sys| +--------------------+ 4rowsinset(0.00sec) mysql>
修改密码安全策略,改为LOW,密码长度最小6位
mysql>SHOWVARIABLESLIKE'validate_password%'; +--------------------------------------+--------+ |Variable_name|Value| +--------------------------------------+--------+ |validate_password.check_user_name|ON| |validate_password.dictionary_file|| |validate_password.length|8| |validate_password.mixed_case_count|1| |validate_password.number_count|1| |validate_password.policy|MEDIUM| |validate_password.special_char_count|1| +--------------------------------------+--------+ 7rowsinset(0.00sec) mysql>setglobalvalidate_password.policy=LOW; QueryOK,0rowsaffected(0.00sec) mysql>setglobalvalidate_password.length=6; QueryOK,0rowsaffected(0.00sec) mysql>SHOWVARIABLESLIKE'validate_password%'; +--------------------------------------+-------+ |Variable_name|Value| +--------------------------------------+-------+ |validate_password.check_user_name|ON| |validate_password.dictionary_file|| |validate_password.length|6| |validate_password.mixed_case_count|1| |validate_password.number_count|1| |validate_password.policy|LOW| |validate_password.special_char_count|1| +--------------------------------------+-------+ 7rowsinset(0.00sec)
关于mysql密码策略相关参数;
1)、validate_password.length 固定密码的总长度;
2)、validate_password_dictionary_file指定密码验证的文件路径;
3)、validate_password_mixed_case_count 整个密码中至少要包含大/小写字母的总个数;
4)、validate_password_number_count 整个密码中至少要包含阿拉伯数字的个数;
5)、validate_password.policy指定密码的强度验证等级,默认为MEDIUM;
6)、validate_password_special_char_count整个密码中至少要包含特殊字符的个数;
关于validate_password.policy的取值:
LOW:只验证长度;
MEDIUM:验证长度、数字、大小写、特殊字符;
STRONG:验证长度、数字、大小写、特殊字符、字典文件;
总结
到此这篇关于CentOS7.8安装mysql8.0.20的文章就介绍到这了,更多相关CentOS7.8安装mysql8.0.20内容请搜索毛票票以前的文章或继续浏览下面的相关文章希望大家以后多多支持毛票票!