vlambda博客
学习文章列表

若依RuoYi框架浅析 部署篇②——CentOS 8 配置MySQL 8.0

目录

  • 一、dnf安装

  • 二、开机自启动

  • 三、查看状态

  • 四、安全设置

  • 五、开放远程连接

  • 六、DataGrip远程连接

  • 七、新建数据库

  • 八、导入sql文件

  • 参考


官方文档:Installing MySQL on Linux

一、dnf安装

CentOS 8 支持dnf,dnf安装MySQL

sudo dnf install @mysql

二、开机自启动

[root@iZ2ze30dygwd6yh7gu6lskZ ~]# sudo systemctl enable --now mysqld
Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service.

三、查看状态

[root@iZ2ze30dygwd6yh7gu6lskZ ~]# sudo systemctl status mysqld
● mysqld.service - MySQL 8.0 database server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2021-02-17 10:30:16 CST; 38s ago
Process: 27178 ExecStartPost=/usr/libexec/mysql-check-upgrade (code=exited, status=0/SUCCESS)
Process: 27052 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mysqld.service (code=exited, status=0/SUCCESS)
Process: 27027 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
Main PID: 27134 (mysqld)
Status: "Server is operational"
Tasks: 39 (limit: 26213)
Memory: 429.8M
CGroup: /system.slice/mysqld.service
└─27134 /usr/libexec/mysqld --basedir=/usr

Feb 17 10:30:11 iZ2ze30dygwd6yh7gu6lskZ systemd[1]: Starting MySQL 8.0 database server...
Feb 17 10:30:11 iZ2ze30dygwd6yh7gu6lskZ mysql-prepare-db-dir[27052]: Initializing MySQL database
Feb 17 10:30:16 iZ2ze30dygwd6yh7gu6lskZ systemd[1]: Started MySQL 8.0 database server.

四、安全设置

是否进入设置:y

选择密码验证策略等级:2(强)
若依RuoYi框架浅析 部署篇②——CentOS 8 配置MySQL 8.0
输入密码,确认密码
若依RuoYi框架浅析 部署篇②——CentOS 8 配置MySQL 8.0
是否移除匿名用户:y
若依RuoYi框架浅析 部署篇②——CentOS 8 配置MySQL 8.0
是否禁止远程登录:n
若依RuoYi框架浅析 部署篇②——CentOS 8 配置MySQL 8.0
是否移除test数据库:y
若依RuoYi框架浅析 部署篇②——CentOS 8 配置MySQL 8.0
是否重新载入权限表:y
若依RuoYi框架浅析 部署篇②——CentOS 8 配置MySQL 8.0

五、开放远程连接

登录,输入密码
第一次输错了,第二次才输对了

[root@iZ2ze30dygwd6yh7gu6lskZ ~]# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@iZ2ze30dygwd6yh7gu6lskZ ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 8.0.21 Source distribution

Copyright (c) 2000, 2020, 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> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update user set host='%' where user='root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

六、DataGrip远程连接

若依RuoYi框架浅析 部署篇②——CentOS 8 配置MySQL 8.0
若依RuoYi框架浅析 部署篇②——CentOS 8 配置MySQL 8.0

七、新建数据库

若依RuoYi框架浅析 部署篇②——CentOS 8 配置MySQL 8.0

八、导入sql文件

选择:RuoYi-Vue\sql\ry_20210210.sql和quartz.sql

参考

  • CentOS 8 安装MySQL 8.0