CentOS 8上安装MySQL 8.0

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

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

sudo dnf install @mysql

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

CentOS 8上安装MySQL 8.0_第1张图片

CentOS 8上安装MySQL 8.0_第2张图片

 

CentOS 8上安装MySQL 8.0_第3张图片

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

继续安装,

sudo dnf install @mysql

CentOS 8上安装MySQL 8.0_第4张图片

CentOS 8上安装MySQL 8.0_第5张图片

CentOS 8上安装MySQL 8.0_第6张图片

启动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 ~]# 

可以远程访问了

你可能感兴趣的:(linux)