Centos7安装mysq5.7.29

下载MySQL安装包和安装源:

wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
yum -y localinstall mysql57-community-release-el7-11.noarch.rpm 

在线安装MySQL后启动服务且设置开机启动

yum -y install mysql-community-server
systemctl start mysqld
systemctl enable mysqld
systemctl daemon-reload

修改root登录密码

vim /var/log/mysqld.log

Centos7安装mysq5.7.29_第1张图片
登录数据库修改密码

mysql -u root -p
#输入密码
#设置root密码
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
# 设置远程登录
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
flush privileges;
exit;
#开启3306端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent;firewall-cmd --reload;firewall-cmd --list-all;
#重启数据库
systemctl restart mysqld;

你可能感兴趣的:(mysql)