Centos7 安装mysql
一、下载安装包
wget http://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
二、安装mysql源
yum localinstall mysql57-community-release-el7-11.noarch.rpm
三、查看是否成功安装
yum repolist enabled | grep "mysql.*-community.*"
出现以上表示安装成功
四、安装mysql
yum install mysql-community-server
五、启动mysql
systemctl start mysqld
5.1、查看mysql的启动状态
systemctl status mysqld
六、开机启动
systemctl enable mysqld systemctl daemon-reload
七、修改root密码
mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码。
修改密码之前,先修改mysql的密码策略
#登陆到mysql mysql -uroot -p #修改策略 不修改会报错ERROR 1819 (HY000): Your password does not satisfy the #current policy requirements set global validate_password_policy=0;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
八、设置防火墙
开放3306端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent systemctl restart firewalld.service
九、设置mysql可以远程访问
#在mysql 控制台执行 GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'MyPassword' WITH GRANT OPTION;
十、look