当前位置:网站首页>Linux——在Linux系统上安装和启动MySQL
Linux——在Linux系统上安装和启动MySQL
2022-08-07 11:26:00 【叶不修233】
Linux——在Linux系统上安装和启动MySQL
安装
dnf install -y mysql-server
设置开机启动
# 查看 mysql-server 运行状态
systemctl status mysqld
# 为避免防火墙的干扰,在开发环境中,我们通常会关闭 linux 防火墙
systemctl disable firewalld --now
# rm -rf /var/lib/mysql/*
# 将 mysql-server 设置为开机启动,并立即启动
systemctl enable mysqld --now # 耐心等待一会
查看 root 初始密码
# 在启动日志中查看 root 初始密码:
grep "password" /var/log/mysql/mysqld.log
会看到类似如下信息
...is created with an empty password !
初始时,MySQL Server 的 root 账号密码为空。
修改默认 root 密码
使用 root 初始密码连接到 mysql-server,例如:
mysql -u root -p
Enter password: <此处直接回车>
mysql 8.0.26 对于密码的安全性没有默认的要求;
mysql 8.0.29 默认则要求大小写字母数字加特殊字符,且长度要超过 8 位。
输入以下 SQL 语句,将 root 初始密码改为自定义的密码:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '这里写新密码';
放开 root 账号的的远程登录限制
USE mysql;
UPDATE `user` SET `host` = '%' where `user` = 'root' AND `host` = 'localhost';
FLUSH PRIVILEGES;
exit;
验证:退出后使用新密码登录。
降低密码安全性要求,再次重设 root 密码
- 注意:只有重置 root 初始密码之后才能进行相关配置。
第 1 步:查看、并修改相关配置项:
SHOW VARIABLES LIKE 'validate_password%';
set global validate_password.policy=0;
set global validate_password.length=4;
SHOW VARIABLES LIKE 'validate_password%';
第 2 步:重置 root 密码,重置成简单密码:
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
边栏推荐
- mysql中select * for update
- UGUI系列-鼠标移动到按钮上显示信息(Unity3D)
- Construction of CCNA--GNS3 simulation environment and beautification and debugging of SecureCRT8.7 program console
- 项目优化之性能优化(Unity3D)
- Want to save programs?The dongle is too much trouble, try this (Unity3D)
- Swin_Unet & Trans_UNet & Unet & Deeplabv3网络训练结果对比
- 封装、继承和多态
- The use and brief principle of xxl-job
- 下载音/视频文件小技巧
- CCNA-安装SecureCRT 8.7 配合使用GNS3仿真
猜你喜欢
随机推荐
nodejs环境搭建
The problem that the uniapp local plugin list is empty
UGUI series-InputField limits the number of inputs and limits the input format
【Hefei University of Technology】Data Sharing
线程理论和实操
CCNA-DHCP (Dynamic Host Configuration Protocol)
flutter打包
pyautogui practice - 10 lines of code to realize the "solidified desktop" in "Broken Elite"
As the complexity of the model increases, how is overfitting caused?How to solve?
[生物信息]临床研究统计分析成长营14天班
Custom Annotations and Reflections
汉诺塔程序
OTA升级 之 Recovery模式
Introduce several colormaps suitable for matlab
介绍几个适用于matlab的colormap
csv module
this inside the object points to the problem
下载音/视频文件小技巧
Project optimization performance optimization (Unity3D)
QT练手小项目:飞机大战









