centos怎么用wget安装mysql_CentOS7上安装MySQL5.7的数据库流程

本文档介绍了如何在CentOS7上使用wget安装MySQL5.7数据库,包括下载安装源,安装服务,启动服务,设置开机启动,获取并修改root用户的密码,以及允许远程链接的配置步骤。
摘要由CSDN通过智能技术生成

1.选择对应的目录 我是直接在家目录下设置的

[root@xiaomu ~]# wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

如果没有wget的话,可以先执行

yum -y install wget

再执行上述的wget的指令

2.检查是否下载完毕

[root@xiaomu ~]# ls

mysql57-community-release-el7-11.noarch.rpm

3.安装MySQL安装源

[root@xiaomu ~]# yum -y localinstall mysql57-community-release-el7-11.noarch.rpm

4.安装MySQL服务【这个稍微耗时】

[root@xiaomu ~]# yum -y install mysql-community-server

5.启动服务

[root@xiaomu ~]# systemctl start mysqld

6.设置开机启动

[root@xiaomu ~]# systemctl enable mysqld

[root@xiaomu ~]# systemctl daemon-reload

7.获取登陆数据库时root用户的默认密码

mysql安装完成之后,会在/var/log/mysqld.log文件中给root生成了一个临时的默认密码

[root@xiaomu ~]# cat /var/log/mysqld.log

8.使用这个密码登陆数据库

[root@xiaomu ~]# 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.29

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

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>

9.修改数据库root用户对应的密码

mysql> alter user 'root'@'localhost' identified by '要设置的密码';

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

注意:这个问题说的是密码策略问题: 权限过高 或者密码长度不够(默认8位)

解决方案

mysql> set global validate_password_policy=LOW;

Query OK, 0 rows affected (0.00 sec)

然后再执行

mysql> alter user 'root'@'localhost' identified by '要设置的密码';

Query OK, 0 rows affected (0.00 sec)

10.设置允许远程链接

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '你设置的密码' WITH GRANT OPTION;

Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;

Query OK, 0 rows affected (0.00 sec)

退出

mysql> exit

Bye

之后再使用新密码登陆即可

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值