linux下安装mysql

mkdir mysql                                                                          --创建MySQL专属文件夹
wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm             --安装MySQL5.7版本
rpm -qpl mysql57-community-release-el7-7.noarch.rpm                                  --查看安装包内容
rpm -ivh mysql57-community-release-el7-7.noarch.rpm                                  --安装rpm包
yum list Mysql*                                                                      --生成MySQL安装包
yum install mysql-community-server                                                   --安装社区版MySQL
service mysqld start                                                                 --启动MySQL
grep "password" /var/log/mysqld.log                                                  --查看MySQL初始密码
mysql -uroot -p                                                                      --用初始密码登录MySQL SET PASSWORD = PASSWORD('YYBrhr_2018');                                                      --设置新密码
 ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
 flush privileges;

   远程连接授权

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

  防火墙开放数据库端口(默认3306,可以在/etc/my.cnf中修改)

【1】查看目前防火墙

firewall-cmd --list-all 

【2】开放3306端口

 firewall-cmd --permanent --add-port=3306/tcp

【3】重启防火墙

service firewalld restart

【4】查看3306端口是否开放

 firewall-cmd --query-port=3306/tcp

【5】再次查看现在防火墙

firewall-cmd --list-all 

【6】连接数据库

 

其他端口开放

/sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT

查看单个端口

netstat  -anp  |grep 8080

查看全部端口

netstat   -nultp

已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页