centos8安装mysql5.7

1.添加MySQL5.7仓库

关闭Centos8中MySQL默认的AppStream仓库:

sudo dnf remove @mysql
sudo dnf module reset mysql && sudo dnf module disable mysql

目前还没有EL8版本的MySQL仓库,所以我们这里用EL7的代替,创建一个新的仓库文件:

sudo vi /etc/yum.repos.d/mysql-community.repo

然后将以下内容粘贴到新建的仓库文件中:

[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
enabled=1
gpgcheck=0

[mysql-connectors-community]
name=MySQL Connectors Community
baseurl=http://repo.mysql.com/yum/mysql-connectors-community/el/7/$basearch/
enabled=1
gpgcheck=0

[mysql-tools-community]
name=MySQL Tools Community
baseurl=http://repo.mysql.com/yum/mysql-tools-community/el/7/$basearch/
enabled=1
gpgcheck=0

2.开始安装MySQL5.7

sudo dnf --enablerepo=mysql57-community install mysql-community-server

3.自动启动和安全配置

sudo systemctl enable --now mysqld.service

然后获取mysql初始密码,用于后续安装配置操作:

grep 'A temporary password' /var/log/mysqld.log |tail -1

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

sudo mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root:

输入刚才获取的初始密码,开始配置:

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!

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

登录mysql:

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

重启数据库:

service mysqld restart
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值