MySQL下载

可以选择去阿里云开源镜像站进行下载

MySQL安装
## 解压缩包
[root@MySQL33 ~]# tar xf MySQL-5.7.36-1.el7.x86_64.tar 
[root@MySQL33 ~]# cd MySQL-5.7.36-1.el7.x86_64/
[root@MySQL33 MySQL-5.7.36-1.el7.x86_64]# ls
mysql-community-client-5.7.36-1.el7.x86_64.rpm
mysql-community-common-5.7.36-1.el7.x86_64.rpm
mysql-community-devel-5.7.36-1.el7.x86_64.rpm
mysql-community-embedded-5.7.36-1.el7.x86_64.rpm
mysql-community-embedded-compat-5.7.36-1.el7.x86_64.rpm
mysql-community-embedded-devel-5.7.36-1.el7.x86_64.rpm
mysql-community-libs-5.7.36-1.el7.x86_64.rpm
mysql-community-libs-compat-5.7.36-1.el7.x86_64.rpm
mysql-community-server-5.7.36-1.el7.x86_64.rpm
mysql-community-test-5.7.36-1.el7.x86_64.rpm
## 使用yum安装rpm包
[root@MySQL33 MySQL-5.7.36-1.el7.x86_64]# yum -y install mysql-community-*.rpm
## 设置MySQL服务开机自启并且立即启动
[root@MySQL33 ~]# systemctl enable --now mysqld
## 查看3306端口有没有正常启动
[root@MySQL33 ~]# ss -tunlp | grep :3306
tcp    LISTEN     0      80       :::3306                 :::*                   users:(("mysqld",pid=20089,fd=21))
## 查看MySQL的默认密码,后12位
[root@MySQL33 ~]# grep password  /var/log/mysqld.log | tail -1
2023-05-06T03:31:05.097081Z 1 [Note] A temporary password is generated for root@localhost: W4wv;wjswG,m
## 连接MySQL
[root@MySQL33 ~]# mysql -hlocalhost -uroot -p'W4wv;wjswG,m'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.36

Copyright (c) 2000, 2021, 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  root用户的密码
mysql> alter user root@"localhost" identified by "000Qqq...";
Query OK, 0 rows affected (0.00 sec)

## 创建用户admin,允许所有IP登录,密码为000Qqq...
mysql> create user'admin'@'%' identified by '000Qqq...';
Query OK, 0 rows affected (0.00 sec)

## 赋予admin拥有管理员权限
mysql> GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' IDENTIFIED BY '000Qqq...'  WITH GRANTOPTION MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNNE
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)