Centos8.5安装mysql
时间: 2023-12-09 10:36:06 浏览: 161
CentOS-8.5.2111-x86_64-boot.iso
以下是在CentOS 8.5上安装MySQL的步骤:
1.使用以下命令安装MySQL存储库:
```shell
sudo dnf install https://dev.mysql.com/get/mysql80-community-release-el8-1.noarch.rpm
```
2.安装MySQL服务器:
```shell
sudo dnf install mysql-community-server
```
3.启动MySQL服务:
```shell
sudo systemctl start mysqld
```
4.检查MySQL服务状态:
```shell
sudo systemctl status mysqld
```
如果MySQL服务正在运行,则输出应该类似于以下内容:
```
● mysqld.service - MySQL 8.0 database server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2021-11-01 09:00:00 CST; 1h ago
```
5.运行MySQL安全性脚本:
```shell
sudo mysql_secure_installation
```
该脚本将提示您设置MySQL root用户的密码,删除匿名用户,禁用root用户的远程登录等。
6.登录MySQL:
```shell
sudo mysql -u root -p
```
7.在MySQL shell中创建新用户并授予访问权限:
```mysql
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'newuser'@'localhost' WITH GRANT OPTION;
```
请将“newuser”和“password”替换为您要创建的用户名和密码。
阅读全文