1.先关闭防火墙和selinuxsystemctlstopfirewalld#closefirewallsetenforce0#closeselinux然后去官网下载安装包mysql官网:mysql.com到最后我选择linux7下载和rz上传【root@localhost~]#rz[root@localhost~]#lsanaconda-ks.cfgmysql80-community-release-el7-3.noarch.rpm2。安装mysql的yum仓库[root@localhost~]#rpm-ivhmysql80-community-release-el7-3.noarch.rpmyum-yinstallyum-utils#安装yum工具包3.配置yum源vim/etc/yum.repos.d/mysql-community.repo#修改如下1表示打开,0表示关闭或者直接修改配置文件,代码#yum-config-manager--enablemysql57-community启用禁用的yum源库#yum-config-manager--disablemysql80-community禁用启用的yum源库4.安装数据库[root@localhost~]#yuminstall-ymysql-community-server[root@localhost~]#systemctlstartmysqld#启动服务[root@localhost~]#systemctlenablemysqld#设置开机5.查找密码[root@localhost~]#greppassword/var/log/mysqld.log2020-03-03T12:29:06.636347Z1【注意】生成临时密码forroot@localhost:ZxrbO,&dl7oU最后是没有空格的密码6.修改密码[root@localhost~]#mysql-uroot-p'ZxrbO,&dl7oU'#登录二两种方式:第一种:mysql>alteruser'root'@'localhost'identifiedby'yournewpassword';第二:[root@localhost~]#mysqladmin-uroot-p'ZxrbO,&dl7oU'password'你的新密码'注意:修改密码必须有大小写数字和特殊符号。
