安装配置MySQL的yum源
https://dev.mysql.com/downloads/repo/yum/ 找到最新的yum源
下载yum源,以mysql8.0为例子
centos 7
wget https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
centos 6
wget https://repo.mysql.com//mysql80-community-release-el6-1.noarch.rpm
安装yum源,以centos 6为例子
rpm -ivh mysql80-community-release-el6-1.noarch.rpm
安装
安装mysql-server
yum install mysql-server
查看mysql临时密码(高版本的mysql密码不为空,需要在日志中查看)
执行下面命令
cat /var/log/mysqld.log | grep "generated for root@localhost"
返回结果:
2018-07-19T03:58:05.916528Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: t>byqD<K_8ak
冒号后面的t>byqD<K_8ak 就是密码
修改mysql密码(临时密码是不能操作的)
密码必须有数字+大写字母+小写字母+字符,比如密码如下
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Fuckdangwu&&00';
否则就会提示(这个可以在my.cnf配置去掉)
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
开始远端权限
创建用户
create user 'chuhe'@'%' identified by 'Fuckdangwu&1314';
给用户授权
grant all privileges on *.* to 'chuhe'@'%' with grant option;
修改用户密码加密方式(为了兼容老版本的client)
ALTER USER 'chuhe'@'%' IDENTIFIED WITH mysql_native_password BY 'Fuckdangwu&131';
开启3306端口
iptables -A INPUT -p tcp --dport 3306 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 3306 -j ACCEPT
service iptables save
service iptables restart