CentOS 安装MYSQL

查看Linux 版本

uname -a
Linux iZ2ze9foeig0mb0yaofw8iZ 4.19.91-24.1.al7.x86_64 #1 SMP Wed Jul 21 17:40:23 CST 2021 x86_64 x86_64 x86_64 GNU/Linux

下载mysql源

wget https://repo.mysql.com//mysql80-community-release-el7-5.noarch.rpm 

安装mysql源

yum -y install mysql80-community-release-el7-5.noarch.rpm

查看一下安装效果

yum repolist enabled | grep mysql.*
mysql源
mysql源

用yum命令直接安装

yum install mysql-community-server -y

阿里云的基本会安装成功

启动mysql服务

systemctl start  mysqld.service

查看服务运行状况

run-status
run-status

初始化数据库

查看初始密码

grep "password" /var/log/mysqld.log
passwd
passwd

登录

mysql -uroot -p

修改密码

ALTER USER 'root'@'localhost' IDENTIFIED BY '****************';

支持远程登录

mysql -uroot -p
use mysql; 
update user set host = '%' where user = 'root'; 
select host, user from user;
result
result

自动启动

systemctl enable mysqld
systemctl daemon-reload