Mysql 安装
Mysql 是常用的轻量级关系型数据库,也是常见的数据库软件之一,今天记录一下安装mysql的方法,便以后使用
1、软件准备
01_mysql-community-common-5.7.16-1.el7.x86_64.rpm 02_mysql-community-libs-5.7.16-1.el7.x86_64.rpm 03_mysql-community-libs-compat-5.7.16-1.el7.x86_64.rpm 04_mysql-community-client-5.7.16-1.el7.x86_64.rpm 05_mysql-community-server-5.7.16-1.el7.x86_64.rpm mysql-connector-java-5.1.27-bin.jar
下载地址
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
链接:https://pan.baidu.com/s/1MPb__Quvtj1oTKW5LOBQPQ 提取码:4fqu
2、卸载之前的mysql
sudo rpm -qa | grep -i -E mysql\|mariadb | xargs -n1 sudo rpm -e --nodeps
3、安装
[hui@hadoop302 software]$ sudo rpm -ivh 01_mysql-community-common-5.7.16-1.el7.x86_64.rpm 警告:01_mysql-community-common-5.7.16-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY 准备中... ################################# [100%] 正在升级/安装... 1:mysql-community-common-5.7.16-1.e################################# [100%] [hui@hadoop302 software]$ sudo rpm -ivh 02_mysql-community-libs-5.7.16-1.el7.x86_64.rpm 警告:02_mysql-community-libs-5.7.16-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY 准备中... ################################# [100%] 正在升级/安装... 1:mysql-community-libs-5.7.16-1.el7################################# [100%] [hui@hadoop302 software]$ sudo rpm -ivh 03_mysql-community-libs-compat-5.7.16-1.el7.x86_64.rpm 警告:03_mysql-community-libs-compat-5.7.16-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY 准备中... ################################# [100%] 正在升级/安装... 1:mysql-community-libs-compat-5.7.1################################# [100%] [hui@hadoop302 software]$ sudo rpm -ivh 04_mysql-community-client-5.7.16-1.el7.x86_64.rpm 警告:04_mysql-community-client-5.7.16-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY 准备中... ################################# [100%] 正在升级/安装... 1:mysql-community-client-5.7.16-1.e################################# [100%] [hui@hadoop302 software]$ sudo rpm -ivh 05_mysql-community-server-5.7.16-1.el7.x86_64.rpm 警告:05_mysql-community-server-5.7.16-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY 准备中... ################################# [100%] 正在升级/安装... 1:mysql-community-server-5.7.16-1.e################################# [100%]
4、启动&配置
sudo systemctl start mysqld
查看初始密码
sudo cat /var/log/mysqld.log | grep password
登录mysql设置密码策略&修改密码
说明:密码策略生产环境建议慎重修改,这里是学习环境所以设置了极简策略。
mysql -uroot -p'jdkAkGdca5>K' mysql> set global validate_password_length=4; mysql> set global validate_password_policy=0;
set password=password("521hui");
select user, host from user; update user set host="%" where user="root"; flush privileges;