配置MySQL

配置MySQL_5.7.16

  • 一级目录
    • 2.1.1 安装包准备
    • 2.1.2 安装MySQL
    • 2.1.3 配置MySQL

一级目录

2.1.1 安装包准备

1)将安装包和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)卸载自带的Mysql-libs(如果之前安装过MySQL,要全都卸载掉)
rpm -qa | grep -i -E mysql\|mariadb | xargs -n1 sudo rpm -e --nodeps

3)如果是阿里云服务器按照如下步骤执行
说明:由于阿里云服务器安装的是Linux最小系统版,没有如下工具,所以需要安装。
(1)卸载MySQL依赖,虽然机器上没有装MySQL,但是这一步不可少
[atguigu@hadoop102 software]# sudo yum remove mysql-libs
(2)下载依赖并安装
[atguigu@hadoop102 software]# sudo yum install libaio
[atguigu@hadoop102 software]# sudo yum -y install autoconf

2.1.2 安装MySQL

1)安装MySQL依赖
sudo rpm -ivh 01_mysql-community-common-5.7.16-1.el7.x86_64.rpm
sudo rpm -ivh 02_mysql-community-libs-5.7.16-1.el7.x86_64.rpm
sudo rpm -ivh 03_mysql-community-libs-compat-5.7.16-1.el7.x86_64.rpm
2)安装mysql-client
sudo rpm -ivh 04_mysql-community-client-5.7.16-1.el7.x86_64.rpm
3)安装mysql-server
sudo rpm -ivh 05_mysql-community-server-5.7.16-1.el7.x86_64.rpm
注意:如果报如下错误,这是由于yum安装了旧版本的GPG keys所造成,从rpm版本4.1后,在安装或升级软件包时会自动检查软件包的签名。
warning: 05_mysql-community-server-5.7.16-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
libaio.so.1()(64bit) is needed by mysql-community-server-5.7.16-1.el7.x86_64
解决办法
[atguigu@hadoop102 software]$ sudo rpm -ivh 05_mysql-community-server-5.7.16-1.el7.x86_64.rpm --force --nodeps

4)启动MySQL
sudo systemctl start mysqld
5)查看MySQL密码
sudo cat /var/log/mysqld.log | grep password

[gpb@hadoop102 software]$ sudo cat /var/log/mysqld.log | grep password
2023-08-27T09:43:04.197213Z 1 [Note] A temporary password is generated for root@localhost: dEZh:g9dheah

2.1.3 配置MySQL

配置只要是root用户 + 密码,在任何主机上都能登录MySQL数据库。
1)用刚刚查到的密码进入MySQL(如果报错,给密码加单引号)
mysql -uroot -p'dEZh:g9dheah'
2)设置复杂密码(由于MySQL密码策略,此密码必须足够复杂)
set password=password("Qs23=zs32");
3)更改MySQL密码策略
set global validate_password_length=4;
set global validate_password_policy=0;
4)设置简单好记的密码
set password=password("000000");
5)进入MySQL库
use mysql
6)查询user表
select user, host from user;
7)修改user表,把Host表内容修改为%
update user set host="%" where user="root";
8)刷新
flush privileges;
9)退出
quit;

你可能感兴趣的:(#,数据仓库,mysql,adb,android)