CentOS 8上安装MySQL 8.0

本文详细介绍了在CentOS8操作系统上安装MySQL8.0数据库服务器的过程,包括解决网络连接问题、启动服务、登录数据库、修改密码、设置远程访问及关闭防火墙等关键步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

CentOS 8操作系统上安装MySQL 8.0,可从默认的CentOS 8存储库中安装最新版本的MySQL数据库服务器8.0版

(1)通过以root用户使用CentOS软件包管理器来安装MySQL 8.0服务器:

sudo dnf install @mysql

出现错误,ip addr查看ip,原来是网络没有链接

 

勾选自动连接,保存后,ip addr查看已经有了ip

继续安装,

sudo dnf install @mysql

启动mysql服务

systemctl start mysqld.service

登录mysql

mysql -u root -p

密码是空的,直接按回车

[root@localhost ~]# systemctl start mysqld.service
[root@localhost ~]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.17 Source distribution

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

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;
 

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

mysql> 

修改密码

ALTER USER 'root'@'localhost' IDENTIFIED  BY '新密码';

mysql> ALTER USER 'root'@'localhost' IDENTIFIED  BY 'Root_123456';
Query OK, 0 rows affected (0.00 sec)

mysql> 

修改远程访问

CREATE USER 'root'@'%' IDENTIFIED BY 'Root_123456';
GRANT ALL ON *.* TO 'root'@'%';
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'Root_123456';

flush privileges;

mysql> CREATE USER 'root'@'%' IDENTIFIED BY 'Root_123456';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL ON *.* TO 'root'@'%';
Query OK, 0 rows affected (0.00 sec)

mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'Root_123456';
Query OK, 0 rows affected (0.01 sec)

关闭防火墙
systemctl stop firewalld.service

[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# 

可以远程访问了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值