大数据基础设施搭建 - MySQL
文章目录
- 一、检查是否安装过MySQL
- 二、上传安装包
- 三、安装MySQL
- 3.1 安装mysql依赖
- 3.2 安装mysql-client
- 3.3 安装mysql-server
- 四、启动MySQL
- 五、配置MySQL
- 5.1 修改密码
- (1)查看密码
- (2)登陆
- (3)设置复杂密码
- (4)更改mysql密码策略
- (5)设置简单密码
- 5.2 设置MySQL允许其他机器登陆root账号
- (1)进入msyql库
- (2)查询user表
- (3)修改user表,把Host表内容修改为%
- (4)刷新
- (5)退出
一、检查是否安装过MySQL
[mall@mall ~]$ rpm -qa | grep mysql
[mall@mall ~]$ rpm -qa | grep mariadb
[mall@mall ~]$ rpm -qa | grep -i -E mysql\|mariadb | xargs -n1 sudo rpm -e --nodeps
二、上传安装包
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
三、安装MySQL
3.1 安装mysql依赖
[mall@mall mysql]$ sudo rpm -ivh 01_mysql-community-common-5.7.16-1.el7.x86_64.rpm
[mall@mall mysql]$ sudo rpm -ivh 02_mysql-community-libs-5.7.16-1.el7.x86_64.rpm
[mall@mall mysql]$ sudo rpm -ivh 03_mysql-community-libs-compat-5.7.16-1.el7.x86_64.rpm
3.2 安装mysql-client
[mall@mall mysql]$ sudo rpm -ivh 04_mysql-community-client-5.7.16-1.el7.x86_64.rpm
3.3 安装mysql-server
[mall@mall mysql]$ sudo rpm -ivh 05_mysql-community-server-5.7.16-1.el7.x86_64.rpm
可能会报缺少依赖的错误!执行下面命令即可: [mall@mall mysql]$ sudo yum install libaio
四、启动MySQL
[mall@mall mysql]$ sudo systemctl start mysqld
五、配置MySQL
5.1 修改密码
(1)查看密码
[mall@mall mysql]$ sudo cat /var/log/mysqld.log | grep password
(2)登陆
mysql -uroot -p 'password'
(3)设置复杂密码
mysql> set password=password("Qs23=zs32");
(4)更改mysql密码策略
mysql> set global validate_password_length=4;
mysql> set global validate_password_policy=0;
(5)设置简单密码
mysql> set password=password("123456");
5.2 设置MySQL允许其他机器登陆root账号
(1)进入msyql库
mysql> use mysql
(2)查询user表
mysql> select user, host from user;
(3)修改user表,把Host表内容修改为%
mysql> update user set host="%" where user="root";
(4)刷新
mysql> flush privileges;
(5)退出
mysql> quit;