码迷,mamicode.com
首页 > 数据库 > 详细

mysql修改root密码

时间:2015-03-19 10:12:23      阅读:190      评论:0      收藏:0      [点我收藏+]

标签:

  1. 首先停止mysql服务
/etc/init.d/mysql stop

     2. 接着采用忽略密码认证模式重新创建一个mysql服务

 mysqld --user=mysql --skip-grant-tables --skip-networking & 

     成功启动后返回PID及其它启动信息

[1] 3591 
root@webserver:/home/webmaster# 121005 2:59:27 [Note] Plugin FEDERATED is disabled. 
121005 2:59:27 InnoDB: The InnoDB memory heap is disabled 
121005 2:59:27 InnoDB: Mutexes and rw_locks use GCC atomic builtins 
121005 2:59:27 InnoDB: Compressed tables use zlib 1.2.3.4 
121005 2:59:27 InnoDB: Initializing buffer pool, size = 128.0M 
121005 2:59:27 InnoDB: Completed initialization of buffer pool 
121005 2:59:27 InnoDB: highest supported file format is Barracuda. 
121005 2:59:27 InnoDB: Waiting for the background threads to start 
121005 2:59:28 InnoDB: 1.1.8 started; log sequence number 1595685 
121005 2:59:28 [Note] mysqld: ready for connections. 
Version: 5.5.24-0ubuntu0.12.04.1 socket: /var/run/mysqld/mysqld.sock port: 0 (Ubuntu) 

 

     3. 连接到mysql系统库

 mysql -u root mysql 

     4. 连接到mysql库后直接修改root账号的密码为新的密码‘123456‘

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

mysql> update user set Password=PASSWORD(123456) where user=root; 
Query OK, 3 rows affected (0.00 sec) 
Rows matched: 3 Changed: 3 Warnings: 0 

mysql> FLUSH PRIVILEGES; 
mysql> quit; 
Bye 

 

     5. 中止mysql服务进程

kill 3591

     6.正常启动mysql服务,并用新密码登录mysql服务器

service mysql start

 

mysql修改root密码

标签:

原文地址:http://www.cnblogs.com/longzhongren/p/4349551.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!