博客园 首页 私信博主 显示目录 隐藏目录 管理 动画

MySQL安装

2.1.1 安装包准备

1)卸载自带的Mysql-libs(如果之前安装过mysql,要全都卸载掉)

[atguigu@hadoop102 software]$ rpm -qa | grep -i -E mysql\|mariadb | xargs -n1 sudo rpm -e --nodeps

2)将安装包和JDBC驱动上传到/opt/software,共计6

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

2.1.2 安装MySQL

1)安装mysql依赖

[atguigu@hadoop102 software]$ sudo rpm -ivh 01_mysql-community-common-5.7.16-1.el7.x86_64.rpm

[atguigu@hadoop102 software]$ sudo rpm -ivh 02_mysql-community-libs-5.7.16-1.el7.x86_64.rpm

[atguigu@hadoop102 software]$ sudo rpm -ivh 03_mysql-community-libs-compat-5.7.16-1.el7.x86_64.rpm

2)安装mysql-client

[atguigu@hadoop102 software]$ sudo rpm -ivh 04_mysql-community-client-5.7.16-1.el7.x86_64.rpm

3)安装mysql-server

[atguigu@hadoop102 software]$ sudo rpm -ivh 05_mysql-community-server-5.7.16-1.el7.x86_64.rpm

4)启动mysql

[atguigu@hadoop102 software]$ sudo systemctl start mysqld

5)查看mysql密码

[atguigu@hadoop102 software]$ sudo cat /var/log/mysqld.log | grep password

2.1.3 配置MySQL

配置只要是root用户+密码,在任何主机上都能登录MySQL数据库。

1)用刚刚查到的密码进入mysql(如果报错,给密码加单引号)

[atguigu@hadoop102 software]$ mysql -uroot -p 'password'

2)设置复杂密码(由于mysql密码策略,此密码必须足够复杂)

mysql> set password=password("Qs23=zs32");

3)更改mysql密码策略

mysql> set global validate_password_length=4;

mysql> set global validate_password_policy=0;

4)设置简单好记的密码

mysql> set password=password("000000");

5)进入msyql

mysql> use mysql

6)查询user

mysql> select user, host from user;

7)修改user表,把Host表内容修改为%

mysql> update user set host="%" where user="root";

8)刷新

mysql> flush privileges;

9退出

mysql> quit;

posted @ 2022-05-31 18:47  CHANG_09  阅读(38)  评论(0编辑  收藏  举报