centos7下快速安装mysql

来源:互联网 发布:华林证券软件 编辑:程序博客网 时间:2024/06/08 04:49

centos7下快速安装mysql

CentOS 7的yum源中貌似没有正常安装mysql时的mysql-sever文件,需要去官网上下载

1
2
3
# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
# rpm -ivh mysql-community-release-el7-5.noarch.rpm
# yum install mysql-community-server

成功安装之后重启mysql服务

1
# service mysqld restart

初次安装mysql是root账户是没有密码的

设置密码的方法

# mysql -uroot

mysql> set password for ‘root’@‘localhost’ = password('mypasswd');

mysql> exit

搞定!


远程授权连接mysql

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;

FLUSH   PRIVILEGES;

Centos7 关闭防火墙


1直接关闭防火墙

systemctl stop firewalld.service #停止firewall

systemctl disable firewalld.service #禁止firewall开机启动

2、设置 iptables service

yum -y install iptables-services

如果要修改防火墙配置,如增加防火墙端口3306

vi /etc/sysconfig/iptables 

增加规则

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

保存退出后

systemctl restart iptables.service #重启防火墙使配置生效

systemctl enable iptables.service #设置防火墙开机启动

最后重启系统使设置生效即可。


0 0
原创粉丝点击