linux mariadb忘记密码,忘记MySQL/MariaDB root密码的解决方法
MySQL/MariaDB 的root 密码忘了,不知道改怎么办,下面是修改root 密码步骤。
(1)登录到数据库所在服务器,手工kill 掉MySQL 进程:
kill `cat /mysql-data-directory/hostname.pid`
其中,/mysql-data-directory/hostname.pid 指的是MySQL 数据目录下的.pid 文件,它记录了
MySQL 服务的进程号。
[root@www.linuxidc.com mysql]# kill `cat /data/mysql/maridb1.pid`
(2)使用—skip-grant-tables 选项重启MySQL 服务:
[root@www.linuxidc.com mysql]# cd /usr/local/mysql/bin
[root@www.linuxidc.com bin]# mysqld_safe --skip-grant-tables --user=mysql &
其中--skip-grant-tables意思是启动MySQL 服务的时候跳过权限表认证。
启动后,连接到MySQL 的root 将不需要口令
查看服务是否启动
[root@www.linuxidc.com ~]# ps -ef|grep mysql
root 3895 3056 0 11:16 pts/0 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --skip-grant-tables --user=mysql
mysql 4045 3895 0 11:16 pts/0 00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql/ --datadir=/data/mysql --plugin-dir=/usr/local/mysql//lib/plugin --user=mysql --skip-grant-tables --log-error=/data/mysql/maridb1.err --pid-file=maridb1.pid --socket=/tmp/mysql.sock --port=3306
root 4172 4130 0 11:20 pts/1 00:00:00 grep --color=auto mysql
(3)用空密码的root 用户连接到MySQL,并且更改root 口令:
[root@www.linuxidc.com ~]# mysql -uroot
Welcome to the MariaDB monitor. Commands end with ; or /g.
Your MariaDB connection id is 9
Server version: 10.2.10-MariaDB-log MariaDB Server
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.
MariaDB [(none)]> set password = password('123');
ERROR 1290 (HY000): The MariaDB server is running with the --skip-grant-tables option so it cannot execute this statement
MariaDB [(none)]> use mysql
Database changed
MariaDB [mysql]> update user set password=password('root') where user='root' and host='localhost';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1 Changed: 0 Warnings: 0
此时,由于使用了--skip-grant-tables 选项启动,使用“set password”命令更改密码失败,直
接更新user 表的password 字段后更改密码成功。
(4)刷新权限表,使得权限认证重新生效:
MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
(5)重新用root 登录时,必须输入新口令:
[root@www.linuxidc.com ~]# mysql -uroot
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@www.linuxidc.com ~]# mysql -uroot -proot
Welcome to the MariaDB monitor. Commands end with ; or /g.
Your MariaDB connection id is 12
Server version: 10.2.10-MariaDB-log MariaDB Server
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.
至此密码修改成功
linux mariadb忘记密码,忘记MySQL/MariaDB root密码的解决方法相关推荐
- linux mysql root修复_linux下误删mysql的root用户,解决方法
开始对liunx界面不熟悉,可能由于不小心,把root误删了,怎么办? 1. # killall mysqld 干掉所有mysql进程 2. # mysqld_safe --skip-grant ...
- MySQL忘记/无root密码,强制修改root密码
MySQL忘记/无root密码强制修改root密码 重置MySQL的root密码步骤如下: 步骤一:在命令行输入以下命令强制不检测mysql登录时的密码: 步骤二:在命令行内输入以下命令将mysql的 ...
- mysql 重置root密码 远程访问_重置mysql的root密码以及设置mysql远程登陆权限
root 密码忘记,重置mysql的root密码 :t 一.修改mysql的配置文件my.cnf 1. 在[mysqld]的段中加上一句:skip-grant-tables [mysqld] data ...
- linux下mysql的root密码忘记解决方
linux下mysql的root密码忘记解决方 1.首先确认服务器出于安全的状态,也就是没有人能够任意地连接MySQL数据库. 因为在重新设置MySQL的root密码的期间,MySQL数据库完全出于没 ...
- 在Linux环境下mysql的root密码忘记解决方法
在Linux环境下mysql的root密码忘记解决方法 参考文章: (1)在Linux环境下mysql的root密码忘记解决方法 (2)https://www.cnblogs.com/hgj123/p ...
- 在Linux环境下mysql的root密码忘记解决方法(三种)
这篇文章主要介绍了在Linux环境下mysql的root密码忘记解决方法,详细的介绍了3种解决办法,具有一定的参考价值,有兴趣的可以了解一下. MySQL密码的恢复方法之一 1.首先确认服务器出于安全 ...
- linux忘记mysql登录用户密码_linux中忘记mysql用户root密码解决方案
1.vim /etc/my.cnf [mysqld] skip-grant-tables ##追加此行,跳过权限表, 2.重启mysql systemctl restart mysqld 3.mysq ...
- 在Linux环境下mysql的root密码忘记解决方法 1.首先确认服务器出于安全的状态,也就是没有人能够任意地连接MySQL数据库。 2.修改MySQL的登录设置: # vi /etc/my.c
在Linux环境下mysql的root密码忘记解决方法 1.首先确认服务器出于安全的状态,也就是没有人能够任意地连接MySQL数据库. 2.修改MySQL的登录设置: # vi /etc/my.cnf ...
- mysql linux root密码忘记了怎么办,linux下忘记mysql的root密码解决办法 | 严佳冬
下面就记录一下在linux下忘记mysql的root密码解决办法: 1.vim /etc/my.cnf #编辑文件,找到[mysqld],在下面添加一行skip-grant-tables [my ...
- linux中忘记mysql用户root密码解决方案
linux中忘记mysql用户root密码解决方案 参考文章: (1)linux中忘记mysql用户root密码解决方案 (2)https://www.cnblogs.com/songbao/p/11 ...
最新文章
- python和R对dataframe进行连接、行过滤更新列内容:dplyr、merge、inner、left、right、inner_join、left_join、sort_values、loc
- 001_Maven入门
- bash问题引起的centos系统不能启动
- python输出50-150之间不能被5整除的整数代码解读
- VSCode自定义代码片段3——url大全
- 《计算机网络》第一章:基础知识Part I
- 【agc004d】Teleporter
- airtest运行脚本_airtest之脚本批量运行
- 备受青睐的在线报表工具有哪些?在线报表怎么做?
- java 编码格式 utf 8_关于java生成UTF-8编码格式文件的诡异问题
- GICv3驱动初始化
- (转)注意力机制(Attention Mechanism)在自然语言处理中的应用
- 1.2 说说大学这滩泥淖——《逆袭大学》连载
- 实现简单的英文字母大小写转换
- btrfs 入门使用
- “超人”为什么最后1秒拯救地球?
- php处理证件照_如何使用ps制作证件照
- 普通话测试app怎么样可以不交钱_考了几次普通话,仍无法达到理想成绩?
- 往事如烟 - 高手老胡
- 教程:AT32F435 QSPI 读写W25Q256
热门文章
- 类UNIX操作系统家族发展时间线图谱(1969-2020)
- 延迟和带宽:时延简介、最后一英里、核心网带宽、网络边缘
- koa2 mysql_koa2+vue+mysql 全栈开发记录
- linux下日志文件的查找(tail和grep)
- 云服务器布置_如何选择云服务器 云服务器配置怎么搭配【详解】
- python实现IIR高通低通,带通,带阻滤波器详解及应用案例
- Unity开发《一起来捉妖》教程 | 3.随机妖怪位置及旋转提示
- Slickflow.NET核心开源工作流引擎
- Console.log对象显示
- c# -- 图片缩放方法总结