Linux测试环境搭建详细步骤---mysql快速部署

mysql快速部署

 详细步骤

(1)卸载残留

# 查看有关mysql包
[root@192 mysql]# rpm -qa | grep mysql
mysql80-community-release-el8-1.noarch

# 卸载mysql相关包
[root@192 mysql]# rpm -e --nodeps mysql80-community-release-el8-1.noarch

# 查看是否卸载
[root@192 mysql]# rpm -qa | grep mysql

(2)下载yum源

##wegt下载mysql
[root@192 mysql]# wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm

--2022-10-21 09:39:45--  http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm
正在解析主机 repo.mysql.com (repo.mysql.com)... 23.203.29.47
正在连接 repo.mysql.com (repo.mysql.com)|23.203.29.47|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:9116 (8.9K) [application/x-redhat-package-manager]
正在保存至: “mysql57-community-release-el7-8.noarch.rpm”

100%[==============================================>] 9,116       --.-K/s 用时 0s      

2022-10-21 09:39:46 (255 MB/s) - 已保存 “mysql57-community-release-el7-8.noarch.rpm” [9116/9116])

(3)安装yum源

[root@192 mysql]# rpm -ivh mysql57-community-release-el7-8.noarch.rpm

[root@192 mysql]# yum install mysql-server

[root@192 mysql]# rpm -ivh mysql57-community-release-el7-8.noarch.rpm

(4)查看密码

# 先删除掉mysql文件中的/var/lib/mysql
[root@192 mysql]# rm -rf /var/lib/mysql

# 然后重启mysql服务
[root@192 mysql]# systemctl restart mysqld

# 查看密码
[root@192 mysql]# grep 'temporary password' /var/log/mysqld.log
2022-10-21T01:45:32.169299Z 1 [Note] A temporary password is generated for root@localhost: gPnuC1fdmi;4

(5)登录mysql

# 登录mysql
[root@192 mysql]# mysql -uroot -p临时密码

(6)更改MySQL密码

# 输入命令,设置密码强度:
[root@192 mysql]# set global validate_password_policy=LOW;

# 输入命令,设置密码长度为6,默认为8(若你设的密码超过8位则不需要修改)
[root@192 mysql]# set global validate_password_length=6;

# 设置新密码
[root@192 mysql]# set password=password('123456');
##如若报下方错误,则是你的密码太简单:

(7)登录并查看

[root@192 mysql]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.40

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> set global validate_password_policy=LOW;
Query OK, 0 rows affected (0.00 sec)

mysql> 
mysql> set global validate_password_length=6;
Query OK, 0 rows affected (0.00 sec)

mysql> set password=password('123456');
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> exit
Bye
[root@192 mysql]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.7.40 MySQL Community Server (GPL)

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases; 
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

甘雨降

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值