腾讯云安装mysql并配置远程连接

环境 :
操作系统:centos 7.2
mysql版本: mysql 5.7
MySQL Yum Repository
https://dev.mysql.com/downloads/repo/yum/

本人这里用的是Red Hat Enterprise Linux 7 / Oracle Linux 7 (Architecture Independent), RPM Package

1.首先登录云服务器
2.下载rpm文件,可在任意文件夹下下载

wget https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm

3.安装rpm

rpm -ivh mysql57-community-release-el7-11.noarch.rpm

确认的时候输入y就好了,安装完成之后,在/etc/yum.repos.d目录下新增了两个文件,mysql-community.repo和mysql-community-source.repo
4.yum 安装mysql

yum install mysql-community-server

5.启动mysql服务

systemctl start mysqld

查看mysql状态

查看mysql服务的状态

6.设置mysql开机启动

systemctl enable mysqld
systemctl daemon-reload

7.查找root密码
mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码。通过下面的方式找到root默认密码,然后登录mysql进行修改:

grep 'temporary password' /var/log/mysqld.log

8.登录mysql,密码为刚才查找的密码

mysql -u root -p

9.修改登录密码

set password for 'root'@'localhost'=password('MyNewPass!');

备注:密码必须要包含大小写字符和数字,特殊字符也可以用,太简单会提示错误:Your password does not satisfy the current policy requirements
10.修改/etc/my.cnf配置文件,在[mysqld]下添加编码配置,如下所示:

[mysqld]
character_set_server=utf8
init_connect=’SET NAMES utf8’

11.重启mysql

systemctl restart mysqld

如需配置远程访问,请参考设置mysql允许外部连接访问

你可能感兴趣的:(阿里云(腾讯云))