MySQL reset root password

大概步骤如下:
1:停止mysql服务器
2:使用mysqld_safe启动mysql
3:修改root密码
4:退出,重启mysql服务器


步骤一:停止mysql服务器的几个方法如下:
1. 通过 service mysqld stop 来停止mysql
2. 如果不行,则直接使用kill命令停止myqld服务,首先需要使用 ps aux | grep mysql 来查看mysql相关的进程pid,(使用ps aux可以看到pid为第二列),然后使用 kill -9 XXXX 依次杀掉

步骤二:使用mysqld_safe启动mysql
使用如下命令启动mysql:

mysqld_safe --skip-grant-tables &

直到看到以下提示,才表示启动成功

Starting mysqld daemon with databases from /var/lib/mysql

以root账号登陆mysql

mysql -u root

步骤三:修改mysql root密码

mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User=‘root‘;
mysql> flush privileges;
mysql> quit;

步骤四:重启mysql

时间: 2024-10-08 10:20:48

MySQL reset root password的相关文章

MYSQL更改root password时遇到Access Denied的解决办法

今天在公司虚拟机上装MYSQL之后需要修改root password,然而遇到这样的错误: Access denied for user 'root'@'localhost' (using password:YES) 后来在网上搜了下,找到如下解决办法,测试可用. # /etc/init.d/mysql stop# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &# mysql -u root mysqlmysql&g

windows下新安装的mysql修改root password问题

常用步骤: 1. 在my.ini中的mysqld下添加一行 skip-grant-tables 2.重启mysql后直接进入后,用SQL直接修改password列: C:\> net stop mysqlC:\> net start mysql C:\> mysqlmysql>mysql> use mysqlDatabase changedmysql> UPDATE user SET Password=PASSWORD('newpassword') where USER

mysql forget root password

http://www.rackspace.com/knowledge_center/article/mysql-resetting-a-lost-mysql-root-password MySQL - Resetting a lost MySQL root password The MySQL root password allows full access to the MySQL database and allows for all actions to be undertaken inc

Reset root password in CentOS 7 / RHEL 7

There may be some occasion you will end up with requirement to reset the root password, the occasion comes when you forget root password; follow this guide to reset the password of root. In CentOS, single user mode will help us to achieve our goal of

RHEL7 recover reset root password

If you have lost or forgot root password of RHEL7, you can follow this step to change to a new password, this is different with the RHEL6  single-usermode, 1, press e button in GRUB 2 boot screen. 2, at the end of Linux line add init=/bin/sh and remo

CentOS 7 / RHEL 7 : Reset / Recover forgotten root password

CentOS 7 / RHEL 7 : Reset / Recover forgotten root password October 11, 2014 by sharad chhetri 4 Comments In this post we will learn, how to reset / recover forgotten root password on CentOS 7 / RHEL 7 (Red Hat Enterprise Linux 7). On RHEL 5/6 or Cen

Mysql re-set password, mysql set encode utf8 mysql重置密码,mysql设置存储编码格式

There is a link about how to re-set password. http://database.51cto.com/art/201010/229528.htm words in short, two lines mysql> UPDATE mysql.user SET password=PASSWORD('your_new_password') WHERE User='root'; mysql> FLUSH PRIVILEGES; and about mysql e

安装完绿色版MySQL修改密码:ERROR 1820 (HY000): You must reset your password using ALTER USER statement befo re executing this statement.

mysql> update mysql.user set password=PASSWORD('123456') where User='root';ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement. 参考:http://dev.mysql.com/doc/refman/5.6/en/alter-user.html 直接执行:set

Mac 安装 MySQL 5.7 后登入后无法执行命令【You must reset your password using ALTER USER statement before executing this statement.】

今天在 Mac 上安装了 MySQL 5.7 ,启动服务后,输入 mysql -u root -p 后,输入初始密码程,尝试执行 show databases; 报了一个 You must reset your password using ALTER USER statement before executing this statement. 错误. 参考 Stack Overflow 上一篇文章 https://stackoverflow.com/questions/33467337/re