1、得到下载地址
进入mysql官网 https://dev.mysql.com/downloads/repo/yum/
点击download,然后在“No thanks, just start my download.”处鼠标右键,复制链接地址,获取rpm包的下载地址: https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
2、下载和安装mysql源
要先安装下wget 命令
yum -y install wget
下载 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
3、在线安装Mysql
yum -y install mysql-community-server
由于这个步骤下载的东西比较多,时间有点长,需要耐心等待。
4、启动Mysql服务
[root@ebs-63878 ~]# systemctl start mysqld
5、设置开机启动
[root@ebs-63878 ~]# systemctl enable mysqld
[root@ebs-63878 ~]# systemctl daemon-reload
6、修改root本地登录密码
mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个临时的默认密码
[root@ebs-63878 ~]# vi /var/log/mysqld.log
可以看到临时密码为 mUpyXojr6Q:E
接下来修改密码:
[root@ebs-63878 ~]# mysql -u root -p
Enter password:
输入临时密码 mUpyXojr6Q:E,
然后进入mysql命令行,修改密码为 xxxxx (备注 mysql5.7默认密码策略要求密码必须是大小写字母数字特殊字母的组合,至少8位)
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'xxxxx';
Query OK, 0 rows affected, 1 warning (0.01 sec)
7、设置允许远程登录
Mysql默认不允许远程登录,需要设置下允许远程登录
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'xxxxx' WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.01 sec)
接着退出
mysql> exit;
Bye
防火墙开放3306端口
[root@ebs-63878 ~]# firewall-cmd --zone=public --add-port=3306/tcp --permanent
success
[root@ebs-63878 ~]# firewall-cmd --reload
success
8、配置默认编码为utf8
修改/etc/my.cnf配置文件
[root@ebs-63878 ~]# vi /etc/my.cnf
在[mysqld]下添加编码配置
[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'
编辑保存完 重启mysql服务;
[root@ebs-63878 ~]# systemctl restart mysqld
查看下编码:
mysql> show variables like '%character%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
到此,可以使用sqlyog远程连接mysql了,且安装及配置全部完成。