20191209_Centos7.2使用yum安装mysql
Posted 无止境
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了20191209_Centos7.2使用yum安装mysql相关的知识,希望对你有一定的参考价值。
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的主要内容,如果未能解决你的问题,请参考以下文章
centos7.2 本地yum安装mysql8.0.11-1
解决在centos7.2下YUM安装nginx-1.12.2依赖的问题