码迷,mamicode.com
首页 > 数据库 > 详细

20191209_Centos7.2使用yum安装mysql

时间:2019-12-09 14:18:14      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:col   禁用   firewalld   generate   ase   运行   完成   rate   get   

1. 下载mysql的rpm包

[root@izwz91qnvovd6suufon1ccz ~]# wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm

2. 安装rpm包

[root@izwz91qnvovd6suufon1ccz ~]# yum localinstall -y mysql57-community-release-el7-7.noarch.rpm

3. 安装mysql 5.7

[root@izwz91qnvovd6suufon1ccz ~]# yum install -y mysql-community-server

4. 启动mysql 5.7

[root@izwz91qnvovd6suufon1ccz ~]# systemctl start mysqld.service

5. 查看数据库的状态:

service mysql status

6. MySQL在5.7安装完成之后有一个默认密码, 查看默认密码:

[root@izwz91qnvovd6suufon1ccz ~]# grep ‘temporary password‘ /var/log/mysqld.log
2019-12-09T04:21:12.283622Z 1 [Note] A temporary password is generated for root@localhost: b;M%;tBXw5E8

7. 修改默认密码:

[root@izwz91qnvovd6suufon1ccz ~]# mysql -u root -p
Enter password:  --使用上面的密码进入mysql
mysql> set password = password(‘yourpassword‘);
Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> alter user ‘root‘@‘localhost‘ password expire never; Query OK, 0 rows affected (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql> quit; --退出后再使用密码登陆

8. 赋远程访问权限:

mysql> grant all privileges on *.* to ‘root‘@‘%‘ IDENTIFIED BY ‘yourpassword‘ WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.00 sec)

9. 看下防火墙:

[root@izwz91qnvovd6suufon1ccz ~]# firewall-cmd  --list-all
FirewallD is not running

10. 我这里防火墙没有运行直接可以使用navicat远程访问了, 默认端口3306

11. 关于防火墙:

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. 查看防火墙状态
systemctl status firewalld.service
6. 关闭防火墙
systemctl stop firewalld.service
7. 启动防火墙
systemctl start firewalld
8. 开机禁用防火墙
systemctl disable firewalld
9. 开机启用防火墙
systemctl enable firewalld

 

20191209_Centos7.2使用yum安装mysql

标签:col   禁用   firewalld   generate   ase   运行   完成   rate   get   

原文地址:https://www.cnblogs.com/wxylog/p/12010376.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!