Centos系统mysql 忘记root用户的密码:

第一步:(停掉正在运行的mysql)

[root@maomao ~]# /etc/init.d/mysqld
stop

Stopping
MySQL:                                           
[  OK  ]

 


第二步:使用 “--skip-grant-tables”参数重新启动mysql

[root@mcy400 ~]# cd 到mysql目录,这里到bin目录,会提示“Please do a cd to the mysql installation directory and restart”
[root@mcy400 ~]# ./bin/mysqld_safe
--skip-grant-tables

[root@cy400 ~]# Starting mysqld daemon with
databases from /var/lib/mysql

注意:如果停在这一步的时候,请克隆一个新的会话接着下一步操作

 


第三步:用帐号登录mysql

[root@cy400 ~]# mysql -u root

Welcome to the MySQL monitor.  Commands end with ;
or \g.

Your MySQL connection id is 1

Server version: 5.0.77 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
 


第四步:改变用户数据库

mysql> use mysql

Reading table information for completion of table and column
names

You can turn off this feature to get a quicker startup with
-A

Database changed
 

第五步:修改密码,下面()内的root123为新密码
mysql>
update user set password=password('root123') where
user='root';

Query OK, 3 rows affected (0.00
sec)
Rows matched: 3
 Changed: 3  Warnings:
0
 


第六步:刷新权限表

mysql> flush privileges;

ERROR 1064 (42000): You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right
syntax to use near 'previleges' at line 1

 


第七步:退出mysql

mysql> quit

Bye

 


第八步:对mysql进行重启
[root@cy400 ~]# /etc/init.d/mysqld
restart;

Stopping
MySQL:                                           
[  OK  ]

Starting
MySQL:                                           
[  OK  ]

 


第九步:用更改过的密码重新登录即可。
[root@cy400 ~]# mysql -u root -p

Enter password: admin123

Welcome to the MySQL monitor.  Commands end with ;
or \g.

Your MySQL connection id is 2

Server version: 5.0.77 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> quit

Bye

[root@cy400 ~]#

加入如下自动启动命令 /etc/rc.d/init.d/mysqld start

转载:http://blog.sina.com.cn/s/blog_4488002e0100z574.html

参考:http://blog.chinaunix.net/uid-25266990-id-2921603.html

Centos系统mysql 忘记root用户的密码的更多相关文章

  1. Centos系统mysql 忘记root用户的密码:

    第一步:(停掉正在运行的mysql) [root@maomao ~]# service mysqld stop  Stopping MySQL:                             ...

  2. MySQL忘记root用户密码修改方法

    一般来说在MySQL修改用户密码有好几种方法: 1.修改自己的密码可用: set password=password('123456'); 2.修改其它用户的密码可用: set password fo ...

  3. mysql忘记root用户密码找回步骤

    修改或找回root密码步骤1.修改MySQL的登录设置: # vi /etc/my.cnf 在[mysqld]的段中加上一句:skip-grant-tables 保存并且退出vi. 2.重新启动mys ...

  4. CentOS中对MySql的root用户重置密码

    由于一般的修改ini文件来完成无密码登录数据库容易造成较大风险,所以使用修改启动服务参数的方式来更新user表,达到无密码登陆的目的. 1.关闭系统下运行的mysql服务 (1)杀掉进程号达到关闭目的 ...

  5. MySQL 的“root”用户修改密码

    MySQL 的“root”用户默认状态是没有密码的,所以在 PHP 中您可以使用 mysql_connect("localhost","root"," ...

  6. linux mysql为root用户初始化密码和改变root密码

    初始化密码: 由于安装MySQL完后,MySQL会自动提供一个不带密码的root用户,为了安全起见给root设置密码: #mysqladmin -u root password 123 (123为密码 ...

  7. Linux忘记root用户的密码

    问题: 由于长时间没有操作过自己安装的虚拟机,导致连root用户的密码都忘了,也真是没谁了. 我使用的是centos6.5,今天就记录一下,如何重置root用户的密码. 操作步骤: 步骤一: 当开机启 ...

  8. linux(centos)下mysql忘记root密码

    1.首先确认服务器出于安全的状态,也就是没有人能够任意地连接MySQL数据库. 重新设置MySQL的root密码的期间,MySQL数据库完全出于没有密码保护的  状态下,其他的用户也可以任意地登录和修 ...

  9. CentOS下MySQL忘记root密码解决方法【转载】

    1.首先确认服务器出于安全的状态,也就是没有人能够任意地连接MySQL数据库. 因为在重新设置MySQL的root密码的期间,MySQL数据库完全出于没有密码保护的 状态下,其他的用户也可以任意地登录 ...

随机推荐

  1. css Hack,用IE11模拟测试的,条件注释要找真IE去测,模拟的无效

    <!DOCTYPE html> <!--[if lt IE 7 ]> <html class="ie6 ie"> <![endif]--& ...

  2. 结合 category 工作原理分析 OC2.0 中的 runtime

    绝大多数 iOS 开发者在学习 runtime 时都阅读过 runtime.h 文件中的这段代码: struct objc_class { Class isa  OBJC_ISA_AVAILABILI ...

  3. 反射机制及开源框架xUitls的使用,使用HttpUtils通过断点续传下载文件

    反射: Java反射机制是在运行状态中,对于任意一个类,都能够知道这个类的所有属性和方法: 对于任意一个对象,都能够调用它的任意一个方法和属性 Java反射机制主要提供下面几种用途: 1•在运行时判断 ...

  4. 转:Internal Sales Order (ISO) Process Flow

    本文介绍下内部销售订单Internal Sales Order(ISO)在Oracle EBS中的流程,内部销售订单和组织间转移(Inter-Organization Transfer,IOT)的作用 ...

  5. Python中作用域的特别之处

    def a(): a = [] def aappend(): a.append(1) aappend() print a def b(): b = 1 def bchange(): b += 1 # ...

  6. httpd.conf配置解析php

    PHPIniDir "D:/php-5.3.5" LoadModule php5_module "D:/php-5.3.5/php5apache2_2.dll" ...

  7. Nodejs v4.x.0API文档学习(1)简介

    文档参考地址:https://nodejs.org/dist/latest-v4.x/docs/api/ 简介 下面是用nodejs编写的一个web服务的例子,返回"Hello World& ...

  8. Hadoop源代码分析

    http://wenku.baidu.com/link?url=R-QoZXhc918qoO0BX6eXI9_uPU75whF62vFFUBIR-7c5XAYUVxDRX5Rs6QZR9hrBnUdM ...

  9. Android带头像的用户注册页面

    详细的图文可以到我的百度经验去查看:http://jingyan.baidu.com/article/cd4c2979eda109756e6e60de.html 首先是注册页面的布局: <?xm ...

  10. C# String 前面不足位数补零的方法 PadLeft

    PadLeft(int totalWidth, char paddingChar) //在字符串左边用 paddingChar 补足 totalWidth 长度PadLeft(int totalWid ...