CentOS7 安装mysql5.7

1.查看并卸载mariadb

rpm -qa | grep -i mariadb
rpm -e --nodeps <上条命令查到的数据,如果没有查到就不用卸载>

2.安装mysql

#下载mysql源安装包
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
#安装mysql源
yum localinstall mysql57-community-release-el7-8.noarch.rpm 
#安装mysql服务端
yum install -y mysql-server --nogpgcheck
#启动mysql
systemctl start mysqld.service
#检查mysql状态
systemctl status mysqld.service

3.修改初始密码

#查询初始密码,冒号后面是密码
grep "password" /var/log/mysqld.log
#使用初始密码登录
mysql -uroot -p 
# 直接修改密码,密码强度太低会修改失败
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';

4.开启远程账户登录(默认情况下只能本机登录)

#登录mysql
mysql -uroot -p
#切换数据库并开启远程
use mysql;
grant all privileges on *.* to 'root'@'%'identified by 'password' with grant option;
#刷新权限
flush privileges;
posted @ 2022-02-18 13:28  BugMakerLOL  阅读(164)  评论(0编辑  收藏  举报