【LINUX】Centos安装MySQL5.7rpm

一. 下载rpm安装包

安装前先卸载系统自带的mariadb,和安装依赖libaio.so.1。
下载地址:https://downloads.mysql.com/archives/community/
下载包名:mysql-5.7.36-1.el7.x86_64.rpm-bundle.tar
在这里插入图片描述

二. 上传到服务器,然后解压

[root@mengjian1 package]# tar -vxf mysql-5.7.36-1.el7.x86_64.rpm-bundle.tar 
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

三. 依次安装rpm

[root@mengjian1 mysql]# rpm -ivh mysql-community-server-5.7.36-1.el7.x86_64.rpm --force --nodeps
[root@mengjian1 mysql]# rpm -ivh mysql-community-libs-5.7.36-1.el7.x86_64.rpm --force --nodeps
[root@mengjian1 mysql]# rpm -ivh mysql-community-client-5.7.36-1.el7.x86_64.rpm --force --nodeps
[root@mengjian1 mysql]# rpm -ivh mysql-community-common-5.7.36-1.el7.x86_64.rpm  --force --nodeps
[root@mengjian1 mysql]# rpm -ivh mysql-community-libs-compat-5.7.36-1.el7.x86_64.rpm  --force --nodeps

四. 配置MySQL文件不区分大小写和端口号

配置文件:/etc/my.cnf
端口号默认3306,可参考此处更改
修改my.cnf后需要重启MySQL,同时放开阿里云和linux端口方可连接

# 修改端口号
port=3366

# 配置不区分大小写
lower_case_table_names=1

在这里插入图片描述

五. 启动MySQL

//启动
[root@mengjian1 etc]# systemctl start mysqld
//检查是否启动
[root@mengjian1 etc]# ps aux | grep mysql
mysql    18777  0.4  8.9 1121412 168048 ?      Sl   12:28   0:00 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
root     19692  0.0  0.0 112824   980 pts/0    R+   12:29   0:00 grep --color=auto mysql

六. 配置MySQL开机自启动(可选)

[root@mengjian1 etc]# systemctl deamon-reload
[root@mengjian1 etc]# systemctl daemon-reload

七. 查询默认用户密码

我的是:jbXG74)!_r*W

[root@mengjian1 etc]# cat /var/log/mysqld.log | grep password
2022-05-15T04:28:12.469621Z 1 [Note] A temporary password is generated for root@localhost: jbXG74)!_r*W

八. 登录MySQL并重置密码方可使用

[root@mengjian1 etc]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
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> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('root@2wwW');
Query OK, 0 rows affected, 1 warning (0.00 sec)

//退出重新登录
mysql> exit
Bye
[root@mengjian1 etc]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.36 MySQL Community Server (GPL)

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

九. 开启远程访问

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root@2wwW' WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.00 sec)

//刷新权限
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

十. 远程无法访问,检查云防火墙和linux防火墙3306端口是否开放。

参考:tomcat8080端口

  1. tomcat默认8080端口,需要打开服务器8080端口。
    参考:https://blog.csdn.net/Answerxiaoai/article/details/124682939
  2. 启动后进入不了网页 我用的阿里云还需要添加安全组规则

在这里插入图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值