Linux中数据库修改密码的几种方式

当遗忘MySQL数据库密码时,可以通过多种方式进行修改。一种方法是在/etc/my.cnf配置文件中添加'skip-grant-tables',重启服务后无密码登录进行修改。另外,可以使用SQL语句如'set password'或'update'来更新密码,或者通过mysqladmin工具执行密码更改。对于MySQL 5.7以上版本,密码需符合特定复杂性和长度要求。此外,还可以通过alter user语句设置新密码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  • 忘记密码,怎么修改

1.通过修改配置文件,无密码登录

mysql的配置文件在/etc/my.cnf

[root@bogon ~]# vim /etc/my.cnf

在[mysqld]中添加:skip-grant-tables

[mysqld]
skip-grant-tables

重启MySQL|mariadb服务

[root@bogon ~]# systemctl restart mariadb

登录MySQL|mariadb

[root@bogon ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 

  • 进入MySQL|mariadb
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

afei00123

您的支持是我创作最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值