centos7安装mysql5.7

本人直接在根目录开始的;

1、下载安装包

wget https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm

2、安装源

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

3、检查是否安装成功

yum repolist enabled | grep "mysql.*-community.*"

4、安装mysql

yum install mysql-community-server

5、启动mysql

service mysqld start

6、安装完后,mysql会默认生成一个密码

grep 'temporary password' /var/log/mysqld.log

7、进入启动目录

[root@localhost /]# cd bin
[root@localhost bin]# 

8、使用第6部分密码登录

[root@localhost bin]# grep 'temporary password' /var/log/mysqld.log
2021-09-27T05:35:12.488562Z 1 [Note] A temporary password is generated for root@localhost: ,J#tmsg_h8JU  (注释:密码)
[root@localhost bin]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.35

9、mysql5.7需要初始化,立即修改密码,先修改密码才能进行下次操作;

        修改简单密码:与validate_password_policy的值有关;validate_password_policy有以下取值:

默认是1,即MEDIUM,所以刚开始设置的密码必须符合长度,且必须含有数字,小写或大写字母,特殊字符。
有时候,只是为了自己测试,不想密码设置得那么复杂,譬如说,我只想设置root的密码为123456。
必须修改两个全局参数:

1)、首先,修改validate_password_policy参数的值

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

2)、validate_password_length(密码长度)参数默认为8,我们修改为1

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

3)、此时修改密码

mysql> alter user 'root'@'localhost' identified by 'root';
Query OK, 0 rows affected (0.00 sec)

10、展示所有数据库【找到mysql里面的mysql 数据库】

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

11、使用mysql 数据库

mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

12、赋值,远程账号链接

mysql> grant all privileges on *.* to root @"%" identified by "root" WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.00 sec)

13、修改默认编码

vim /etc/my.cnf

## [mysqld]下增加配置

[mysqld]

character_set_server=utf8

init_connect='SET NAMES utf8'

14、添加到开机启动项

systemctl enable mysqld

systemctl daemon-reload

15、重启mysql

service mysqld restart

16、使用工具链接测试,和说明

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值