通过使用本网站, 您同意 隐私政策.
接受
进入IT进入IT进入IT
  • 家
  • 信息技术专家
  • 技术
  • 微软
    • 天蓝色
    • 配置管理器/SCCM
    • 数字PM
    • 协调者
    • Hyper-V
    • 微软 Edge 预览体验
    • 微星指数
    • 办公室 365
    • 办公室内幕
    • 电力商业智能
    • Skype
    • SQL服务器
    • 团队
  • 视窗
    • Windows 管理中心
    • Windows客户端
    • Windows服务器
  • SCCM查询集合列表
阅读: Reset MySQL Root Password on Linux: 逐步指南
字体调整器氨基酸
进入IT进入IT
字体调整器氨基酸
  • 家
  • 信息技术专家
  • 技术
  • 微软
  • 视窗
  • SCCM查询集合列表
搜索
  • 家
  • 信息技术专家
  • 技术
  • 微软
    • 天蓝色
    • 配置管理器/SCCM
    • 数字PM
    • 协调者
    • Hyper-V
    • 微软 Edge 预览体验
    • 微星指数
    • 办公室 365
    • 办公室内幕
    • 电力商业智能
    • Skype
    • SQL服务器
    • 团队
  • 视窗
    • Windows 管理中心
    • Windows客户端
    • Windows服务器
  • SCCM查询集合列表
MySQL

Reset MySQL Root Password on Linux: 逐步指南

出版: 二月 18, 2024
3 最小阅读量
分享

Reset MySQL Root Password on Linux: 逐步指南.

Losing or forgetting the MySQL root password can be a daunting situation for database administrators. 然而, on a Linux system, there are methods to reset the MySQL root password and regain access to your database. 在本文中, we will guide you through the process of resetting the MySQL root password on Linux by modifying the MySQL configuration file (my.cnf), ensuring the security and integrity of your valuable data.

1. The first step in resetting the MySQL root password is to stop the MySQL service to prevent any active connections. Open a terminal on your Linux system and execute the following command:

sudo systemctl stop mysql

2. 下一个, you need to modify the MySQL configuration file (my.cnf) to disable the authentication process temporarily. Open the file using a text editor:

sudo nano /etc/mysql/my.cnf

Locate the [mysqld] section in the file and add the following line below it:

skip-grant-tables

笔记: In case, when [mysqld] not exist use this code:

[mysqld]
skip-grant-tables

保存更改并退出文本编辑器.

3. After modifying the configuration file, you need to restart the MySQL service for the changes to take effect. Execute the following command in the terminal:

sudo systemctl restart mysql

笔记: The MySQL service will now start without checking the user privileges, allowing you to reset the root password without providing the current password.

4. Now that MySQL is running with the authentication process disabled, open a terminal and connect to the MySQL server using the following command:

mysql -u root

Once connected to the MySQL server, execute the following SQL statement to flush privileges:

FLUSH PRIVILEGES;

笔记: Without it, you will get errors on any user operations.

Once connected to the MySQL server, execute the following SQL statement to update the root password:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';

Replace ‘new_password’ with your desired password. After running the query, you can exit the MySQL prompt by typing exit 或者 quit.

FLUSH PRIVILEGES;
exit;

笔记: Don’t forget to comment code on my.cnf

#[mysqld]
#skip-grant-tables
标记:Almarux中央操作系统dbLinuxMySQLUbuntu
上一篇 How to Update Sysmon on Windows – Step by Step Guide
下一篇 办公室内幕 2212 对于Windows
发表评论 发表评论

发表回复 取消回复

您的电子邮件地址不会被公开. 必填字段已标记 *

该网站使用 Akismet 来减少垃圾邮件. 了解您的评论数据的处理方式.

翻译

English中文(简体)DanskNederlandsFrançaisDeutschItaliano한국어PolskiPortuguêsRomânăEspañolУкраїнська
经过 Transposh - translation plugin for wordpress

热门帖子

Windows Server 的系统要求 2016
Windows服务器
配置管理器查询集合列表
配置管理器查询集合列表
configmgr
在经典团队网站的新式页面上启用结构化/托管导航
技术
SCCM 无法从 MP 获取预期版本的 DP 位置
configmgr

最近的帖子

在 Ubuntu 上安装和配置 Fail2ban 以实现 SSH 保护 24.04
Linux
在AlmaLinux上启用和配置FirewallD
Linux
AlmaLinux中的用户创建和SSH密钥设置
Linux
如何在AlmaLinux上重置密码
Linux

© 2023 进入IT

转到移动版本
欢迎回来!

登录您的帐户

用户名或电子邮件地址
密码

丢失密码?