1.下载 mysql源安装包
wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm2.安装mysql源
yum -y localinstall mysql57-community-release-el7-11.noarch.rpm3.在线安装Mysql (下载的东西比较多 要等一会)
yum -y install mysql-community-server4.启动Mysql服务
systemctl start mysqld5.设置开机启动
[root@localhost ~]# systemctl enable mysqld [root@localhost ~]# systemctl daemon-reload6.修改root本地登录密码(mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个临时的默认密码 (临时密码:fT6uZU9aH))
[root@localhost ~]# vi /var/log/mysqld.log7.输入临时密码 进入mysql命令行
[root@localhost ~]# mysql -u root -p Enter password:输入临时密码8.修改密码 (修改密码为 Zm12345@ (备注 mysql5.7默认密码策略要求密码必须是大小写字母数字特殊字母的组合,至少8位) )
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Zm12345@'; Query OK, 0 rows affected (0.00 sec)9.设置允许远程登录(Mysql默认不允许远程登录,我们需要设置下,并且防火墙开放3306端口)
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Zm12345@' WITH GRANT OPTION; Query OK, 0 rows affected, 1 warning (0.01 sec) mysql> exit; Bye退出后,开放3306端口
[root@localhost ~]# firewall-cmd --zone=public --add-port=3306/tcp --permanent success [root@localhost ~]# firewall-cmd --reload success [root@localhost ~]#10.配置默认编码为utf8
修改/etc/my.cnf配置文件,在[mysqld]下添加编码配置,如下所示:
[root@localhost ~]# vi /etc/my.cnf
[mysqld] character_set_server=utf8 init_connect='SET NAMES utf8'11.编辑保存完 重启mysql服务
[root@localhost ~]# systemctl restart mysqld [root@localhost ~]#12.查看下编码
mysql> show variables like '%character%';至此,安装与配置已完成。可以使用Navicat测试连接
转载于:https://www.cnblogs.com/QW-lzm/p/8822765.html
相关资源:centos7安装配置mysql5.7教程全