centos7 安装mysql8.0

78 阅读1分钟

1.官方文档

dev.mysql.com/doc/mysql-y…

2.下载 Mysql yum包

dev.mysql.com/downloads/r…

或者直接

wget repo.mysql.com/mysql80-com…

3.安装软件源

sudo rpm -Uvh mysql80-community-release-el7-3.noarch.rpm

4.安装mysql服务端

yum install -y mysql-community-server

5.启动mysql

service mysqld start(重启是restart,完全弄好MySQL后最好添加lower_case_table_names=1到[mysqld]下面一行然后重启MySQL,这是为了和windows兼容,还有就是在[mysql]下面一行加入default-character-set=utf8)

6.检查mysql运行状态

service mysqld status

7.查看初始密码

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

8.登录

mysql -uroot -p

9.修改密码

ALTER USER 'root'@'localhost' IDENTIFIED BY '123456;

或者

set password for 'root'@'localhost'=password('123456');

10.若报错ERROR 1819 (HY000): Your password does not satisfy the current policy requirements。

则执行如下两个命令;

set global validate_password.policy=0;

set global validate_password.length=1;

再次执行第9步修改密码

11.添加远程连接账户

create user 'cf'@'%' identified by '123456';

 grant all privileges on *.* to 'cf'@'%' with grant option;

12.使配置生效

FLUSH PRIVILEGES;

13.若navicat 报错  1251 client does not support,则升级navicat 或者 修改权限

ALTER USER 'cf'@'%' IDENTIFIED WITH mysql_native_password BY '123456';

FLUSH PRIVILEGES;

14.安装iptables

yum install iptables-services

15.开机执行

systemctl enable iptables

16.命令:

systemctl start iptables 

systemctl stop iptables

systemctl status iptables

17.添加3306端口

vi /etc/sysconfig/iptables

文件中添加

-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT

wq保存退出,然后重启iptables