centos7安装mysql 5.7

1.下载yum源

 wget https://dev.mysql.com/get/mysql80-community-release-el7-6.noarch.rpm

2.使用下面的命令安装下载的rpm

 sudo rpm -Uvh mysql80-community-release-el7-6.noarch.rpm

3.查询mysql版本

yum repolist all | grep mysql

在这里插入图片描述

4.设置安装的版本

禁用mysql80

sudo yum-config-manager --disable mysql80-community

启用mysql57-community

sudo yum-config-manager --enable mysql57-community

如果报错:

sudo: yum-config-manager: command not found

安装工具:

yum -y install yum-utils

查看可以安装的版本:

yum repolist enabled | grep mysql

5.安装

rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
sudo yum install mysql-community-server

6.启动mysql

systemctl start mysqld

查看状态:

systemctl status mysqld

7.设置自动启动

sudo systemctl enable --now mysqld.service

8.安全设置

查询临时密码:

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

接着开始对mysql进行安全配置,通过MySQL Secure Installation去修改密码、关闭root远程登陆权限,、删除匿名用户、删除测试数据库等:

sudo mysql_secure_installation
Change the password for root ? ((Press y|Y for Yes, any other key for No) : Yes

New password: 
Re-enter new password: 

Estimated strength of the password: 100 
Do you wish to continue with the password provided?: Yes

Remove anonymous users?: Yes
Success.

Disallow root login remotely? : Yes
Success.

Remove test database and access to it? : Yes
 - Dropping test database...
Success.
 - Removing privileges on test database...
Success.

Reload privilege tables now? (Press y|Y for Yes) : Yes
Success.

All done!

9:操作设置任意IP连接访问

mysql -u root -p
use mysql;
select user,host from user;
update user set host='%' where user='root';
FLUSH PRIVILEGES;

10:重启数据库

service mysqld restart

11.优化

编辑/etc/my.cnf

  • 不区分大小写
 lower_case_table_names=1
  • 修改端口:
 port=5666
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值