原来有安装mysql先卸载,自行百度
第一步、下载MySQL 安装包:
wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
安装mysql 安装源:
yum -y localinstall mysql57-community-release-el7-11.noarch.rpm
第二步,在线安装MySQL:
yum -y install mysql-community-server
①、等待时间比较久 note:如果这里发生错误centos7.8安装mysql5.7时Error: Unable to find a match: mysql-community-server
解决:
先执行:yum module disable mysql
再执行:yum -y install mysql-community-server
第三步、启动mysql 服务
systemctl start mysqld
第四步,设置开机启动
[root@localhost local]# systemctl enable mysqld
[root@localhost local]# systemctl daemon-reload
第五步,修改root登录密码
vim /var/log/mysqld.log
记住初始密码,登录后 修改密码。
mysql -u root -p
第六步 修改新密码
新密码 : 大小写、符号、数字、组成不能太简单
第七步设置远程登录
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '密码' WITH GRANT OPTION;
第八步,退出
exit
第九步,防火墙开放3306端口
firewall-cmd --add-port=3306/tcp --permanent
重新载入配置
firewall-cmd --reload
重启防火墙
systemctl reload firewalld
第十步,配置mysql默认编码为utf-8
vim /etc/my.cnf
添加以下代码:
character_set_server=utf8
init_connect='SET NAMES utf8'
第十一步,重启MySQL
systemctl restart mysqld