环境
linux 7.6 mysql 8.0.28
准备
首先看看用没有安装mysql
rpm -qa | grep -i mysql
有就删了
yum remove mysql
vim /etc/yum/pluginconf.d/fastestmirror.conf
删mariadb
rpm -qa | grep mariadb
rpm -e mariadb-libs-5.5.60-1.el7_5.x86_64 --nodeps
删除配置文件
find / -name mysql
rm -rf /usr/lib64/mysql
rm -rf /etc/selinux/targeted/active/modules/100/mysql
删除mysql的默认密码
rm -rf /etc/my.cnf
rm -rf /root/.mysql_sercret
安装
找最新安装包
http://dev.mysql.com/downloads/repo/yum/
下载rpm安装包
wget https://dev.mysql.com/get/mysql80-community-release-el7-5.noarch.rpm
安装mysql源
yum localinstall mysql80-community-release-el7-5.noarch.rpm
安装数据库
yum install mysql-community-server
配置
启动mysql查看状态
service mysqld start
service mysqld status
显示mysql的随机密码
grep 'temporary password' /var/log/mysqld.log
2022-03-25T12:11:30.628821Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: password
登录mysql
mysql -u root -p
修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY "password";
查看密码策略
SHOW VARIABLES LIKE 'validate_password%';
开放远程访问
创建权限用户记录
create user 'root'@'%' identified by 'password';
授权
grant all privileges on *.* to 'root'@'%' with grant option;