mysql忘记密码怎么办??
1、停掉mysql
1.1单实例停止方式
[root@qiuhom ~]# /etc/init.d/mysqld stop
Shutting down MySQL. [ OK ]
1.2多实例停止方式
[root@qiuhom ~]# /data/3306/mysql stop
Stopping MySQL ...
当然停止mysqld的方式有很多比如也可以用kill -9 +mysqld的pid号,killall mysqld 或者pkill mysqld都可以将进程杀死,但是这种简单粗暴的方式我们不推荐。
2、用mysqld_safe 启动数据库
2.1单实例启动
[root@qiuhom ~]# mysqld_safe --skip-grant-tables --user=mysql &
[1] 1285
[root@qiuhom ~]# 181004 17:23:52 mysqld_safe Logging to '/application/mysql-5.5.32/data/qiuhom.err'.
181004 17:23:52 mysqld_safe Starting mysqld daemon with databases from /application/mysql-5.5.32/data [root@qiuhom ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.32-log Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
提示:用mysqld_safe启动数据库一定要加--skip-grant-tables 忽略授权表的方式启动,当然也要指定用户。
通过以上mysqld_safe启动后此时登录数据库就没有密码了 我可以mysql直接进入 也可以mysql -uroot -p 回车 密码为空直接回车也可以进入数据库
2.2多实例启动
[root@qiuhom ~]# mysqld_safe --defaults-file=/data/3306/my.cnf --skip-grant-tables &
[1] 798
[root@qiuhom ~]# 181003 10:16:53 mysqld_safe Logging to '/data/3306/mysql_lee3306.err'.
181003 10:16:53 mysqld_safe Starting mysqld daemon with databases from /data/3306/data [root@qiuhom ~]# mysql -S /data/3306/mysql.sock
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.32-log Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
提示:多实例的启动要指定启动配置文件的位置,--defaults-file 就是用来指定启动配置文件的位置。值得注意的是登录多实例mysql 一定要指定mysql的sock文件
-S 来指定登录mysql的sock文件位置
3、进入数据库后,我们用update对mysql库里的user表进行修改
mysql> update mysql.user set password=password("admin123.com") where user='test' and host='localhost';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select user,host,password from mysql.user;
+------------+-----------+-------------------------------------------+
| user | host | password |
+------------+-----------+-------------------------------------------+
| root | localhost | *4ACFE3202A5FF5CF467898FC58AAB1D615029441 |
| root | 127.0.0.1 | |
| qiuhom | % | *4ACFE3202A5FF5CF467898FC58AAB1D615029441 |
| test | localhost | *2D9AC2437F9E59A51BE8BA89A3D59E76F32F55E8 |
| test | % | *4ACFE3202A5FF5CF467898FC58AAB1D615029441 |
| qiuhom_db1 | localhost | *2D9AC2437F9E59A51BE8BA89A3D59E76F32F55E8 |
| qiuhom_db2 | localhost | *2D9AC2437F9E59A51BE8BA89A3D59E76F32F55E8 |
+------------+-----------+-------------------------------------------+
7 rows in set (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
提示:设置的密码我不能直接写password=“xxx” ,一定要用password函数将自己设置的密码加密,我们在数据库里看到的都是密文密码。用update 修改表里的内容,一定要注意 后面一定要条件,条件越多越精确。最后不要忘记刷新权限哟!!!
4、停止掉mysqld_safe启动的数据库,重新以正常的方式启动数据库
4.1停止mysqld_safe启动的数据库实例(单实例)
[root@qiuhom ~]# mysqladmin -utest -padmin123.com shutdown
181004 17:53:37 mysqld_safe mysqld from pid file /application/mysql-5.5.32/data/qiuhom.pid ended
[1]+ Done mysqld_safe --skip-grant-tables --user=mysql
[root@qiuhom ~]# ps -ef |grep mysql|grep -v grep
[root@qiuhom ~]#
4.2停止mysqld_safe启动的数据库实例(多实例)
[root@qiuhom ~]# mysqladmin -utest -padmin123.com -S /data/3306/mysql.sock shutdown
181003 10:46:59 mysqld_safe mysqld from pid file /data/3306/mysqld.pid ended
[1]+ Done mysqld_safe --defaults-file=/data/3306/my.cnf --skip-grant-tables
[root@qiuhom ~]# ps -ef |grep 3306|grep -v grep
[root@qiuhom ~]#
4.3正常启动mysql(单实例)
[root@qiuhom ~]# /etc/init.d/mysqld start
Starting MySQL [ OK ]
[root@qiuhom ~]# mysql -utest -padmin123.com
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.32-log Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
4.4正常启动mysql(多实例)
[root@qiuhom ~]# /data/3306/mysql start
Starting MySQL...
[root@qiuhom ~]# mysql -utest -padmin123.com -S /data/3306/mysql.sock
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.32-log Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
提示:以上是忘记密码,重新设置密码的流程 不要和mysqladmin混淆,mysqladmin用于空密码设置密码或者知道密码修改密码。多实例的启动一定要加--defaults-file来指定启动配置文件,登录多实例一定要用-S(大写)指定mysql的sock文件。。
mysql忘记密码怎么办??的更多相关文章
- Windows下mysql忘记密码的解决方法
Windows下mysql忘记密码的解决方法 mysql5.0 http://www.jb51.net/article/21984.htm方法一: 1.在DOS窗口下输入 net stop mysql ...
- windows主机mysql忘记密码如何重置
本文主要是针对mysql重置密码过程中出现“mysqld不是内部命令或外部命令”的问题而写的.网上有很多关于mysql忘记密码了如何找回的文章,但是很多说的都不够详细,特别是还要用到DOS命令,可能这 ...
- windows环境下mysql忘记密码如何重置
本文主要是针对mysql重置密码过程中出现“mysqld不是内部命令或外部命令”的问题而写的.网上有很多关于mysql忘记密码了如何找回的文章,但是很多说的都不够详细,特别是还要用到DOS命令,可能这 ...
- ubuntu14下mysql忘记密码的处理
ubuntu14下mysql忘记密码的处理 ubuntu14.04忘记了mysql的用户(root)的密码.接下来: 1) 停止mysql服务 $ sudo stop mysql 2) 启动mysql ...
- MySQL忘记密码怎么修改密码
MySQL的 root 帐号密码默认为空,经常都有修改密码后忘记密码的事.如果忘记了root 帐号密码,那该怎么修改密码呢?这里有一个可行的方法,就是在MySQL安全模式下(跳过权限检查)修改密码的方 ...
- Mysql 忘记密码
Mysql 忘记密码,跳过密码登陆,在更改密码. Linux 系统: 1.查看平时进程:杀掉mysql进程. kill -TERM mysqld 或者 : ps -ef | grep mysqld | ...
- [转]MySQL忘记密码的正确解决方法
http://database.51cto.com/art/201005/201986.htm 以下的文章主要介绍的是MySQL忘记密码的正确解决方法,在实际操作中如果你忘记MySQL密码是一件很头痛 ...
- MySQL忘记密码了怎么办?
接手一个项目时,如果上一位负责人没有把项目文档.账号密码整理好是一件很头疼的事情.. 例如,当你想打开MySQL数据库的时候 输入: mysql -u root -p 一回车想输入密码,发现密码错误! ...
- mysql忘记密码怎么办?(转)
linux下mysql忘记密码处理方法: 1.首先确认服务器出于安全的状态,也就是没有人能够任意地连接MySQL数据库. 因为在重新设置MySQL的root密码的期间,MySQL数据库完全出于没有密码 ...
- Mysql 忘记密码处理配置
Mysql忘记密码处理 1.设置mysql密码 mysqladmin -uroot password ‘密码’ 2.主配置文件下取消密码授权 vim /etc/my.cnf 注:加入skip-gran ...
随机推荐
- 如何在Linux服务器上部署Mysql
一.安装mysql 1.通过文件上传工具,将mysql安装包上传到linux服务器上 2.卸载mariadb包,由于系统中存在mariadb包会导致mysql安装时报错mariadb-libs被mys ...
- 设计模式常见面试知识点总结(Java版)
设计模式 这篇总结主要是基于我设计模式系列的文章而形成的的.主要是把重要的知识点用自己的话说了一遍,可能会有一些错误,还望见谅和指点.谢谢 更多详细内容可以到我的cdsn博客上查看: https:// ...
- MySQL复制从库建立-xtracebackup方式
Percona XtraBackup工具提供了一种在系统运行时执行MySQL数据热备份的方法. Percona XtraBackup在事务系统上执行联机非阻塞,紧密压缩,高度安全的完整备份,因此在计划 ...
- DCL语句
DCL语句我们现在默认使用的都是root用户,超级管理员,拥有全部的权限.但是,一个公司里面的数据库服务器上面可能同时运行着很多个项目的数据库.所以,我们应该可以根据不同的项目建立不同的用户,分配不同 ...
- 代码审计-Beescms_V4.0
Beescms_V4.0代码审计源于一场AWD线下比赛的漏洞源码 看了别的师傅的文章发现这个源码也非常简单 ,所以今晚简单审计过一遍. 0x01 预留后门 awd首先备份源码,然后下载下来查杀后门, ...
- [Luogu4550] 收集邮票
题目描述 有n种不同的邮票,皮皮想收集所有种类的邮票.唯一的收集方法是到同学凡凡那里购买,每次只能买一张,并且买到的邮票究竟是n种邮票中的哪一种是等概率的,概率均为1/n.但是由于凡凡也很喜欢邮票,所 ...
- Cocos2d-x 学习笔记(11.8) DelayTime ReverseTime TargetedAction ActionFloat Blink TintTo TintBy ResizeTo ResizeBy
1. DelayTime 通过create方法create(float d)设置时长,update方法没有任何操作.可以用于动作之间的延迟. 2. ReverseTime create方法create ...
- ESP8266开发之旅 网络篇⑥ ESP8266WiFiGeneric——基础库
1. 前言 在前面的博文中,博主介绍到ESP8266WiFi库是包含了很多功能的一个超级库.ESP8266WiFi库不仅仅局限于 ESP8266WiFi.h 和 ESP8266WiFi.cpp ...
- java 连续数字数组分组
问题: 1. 将Lis list = Arrays.asList(1,2,3,5,8,9,10), 拆分成 [1,2,3] .[5]. [8,9,10] , 2. 再传入一个数字 9, 将匹配数字9的 ...
- python3.x以上 爬虫 使用问题 urllib(不能使用urllib2)
问题一: python 3.x 以上版本揽括了 urllib2,把urllib2 和 urllib 整合到一起. 并且引入模块变成一个,只有 import urllib # import urllib ...