怎么修改忘记mysql root密码码

luckcy 的BLOG
用户名:luckcy
文章数:158
评论数:78
访问量:1174538
注册日期:
阅读量:24883
阅读量:263412
阅读量:1000196
阅读量:149907
51CTO推荐博文
第一种方法:
root用户登录系统
/usr/local/mysql/bin/mysqladmin -u root -p password 新密码
enter password 旧密码
第二种方法:
root用户登录mysql数据库
mysql& update mysql.user set password=password(”新密码”)where User=”root”;
mysql忘记root密码如何处理?
如果 MySQL 正在运行,首先结束mysql进程: killall mysqld
启动 MySQL (非正常方式起动):/usr/local/mysql/bin/mysqld_safe Cskip-grant-tables &
这样就可以不需要密码进入 MySQL :/usr/local/mysql/bin/mysql -u root -p (要求输入密码时直接回车即可)
mysql& update user mysql.set password=password(”新密码”) where user=”root”;
重新结束进程:killall mysqld
用正常方式启动 MySQL :/usr/local/mysql/bin/mysqld_safe -user=mysql &
注: update语句里的password=password(”新密码”)只有新密码三个字在操作时替换成我们要设置的密码,其它原样照写,之前我做失败的原因就在于把括号及前面的password给略掉造成的.它们的作用是使密码以加密的形式存储在数据库里。
了这篇文章
类别:┆阅读(0)┆评论(0)如何设置mysqlroot密码
如何设置mysql root密码:
1、首次安装 root初始密码为空,注意就是没有密码,直接敲回车即可进入
D:\wamp\bin\mysql\mysql5.6.17\bin&mysql -uroot -p
Enter password: [直接回车]
Welcome to the MySQL monitor. C or \g.
Your MySQL connection id is 7
Server version: 5.6.17 MySQL Community Server (GPL)
Copyright (c) , 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
Type '' or '\h' for help. Type '\c' to clear the current input statement.
2、修改root密码的几种方法:
1) 用SET PASSWORD命令
  首先登录MySQL。
  格式:mysql& set password for 用户名@localhost = password('新密码');
  例如:
mysql& set password for root@localhost = password('root');
Query OK, 0 rows affected (0.00 sec)
mysql& quit
D:\wamp\bin\mysql\mysql5.6.17\bin&mysql -uroot -proot
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. C or \g.
Your MySQL connection id is 8
Server version: 5.6.17 MySQL Community Server (GPL)
Copyright (c) , 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
Type '' or '\h' for help. Type '\c' to clear the current input statement.
2)用mysqladmin
  格式:mysqladmin -u用户名 -p旧密码 password 新密码
  例如:
D:\wamp\bin\mysql\mysql5.6.17\bin&mysqladmin -uroot -proot password root123
Warning: Using a password on the command line interface can be insecure.
D:\wamp\bin\mysql\mysql5.6.17\bin&mysql -uroot -proot123
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. C or \g.
Your MySQL connection id is 10
Server version: 5.6.17 MySQL Community Server (GPL)
Copyright (c) , 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
Type '' or '\h' for help. Type '\c' to clear the current input statement.
3)用UPDATE直接编辑user表
  首先登录MySQL。
  mysql&
  mysql& update user set password=password('root') where user='root' and host='localhost';
  mysql&
--注意一定要
mysql 新设置用户或更改密码后需用flush privileges刷新MySQL的系统权限相关表,否则会出现拒绝访问,还有一种方法,就是重新启动mysql服务器,来使新设置生效。
4)在忘记root密码的时候,可以这样。
  以windows为例:
  1. 关闭正在运行的MySQL服务。
  2. 打开DOS窗口,转到mysql\bin目录。
  3. 输入mysqld --skip-grant-tables 回车。--skip-grant-tables 的意思是启动MySQL服务的时候跳过权限表认证。
  4. 再开一个DOS窗口(因为刚才那个DOS窗口已经不能动了),转到mysql\bin目录。
  5. 输入mysql回车,如果成功,将出现MySQL提示符 &。
  6. 连接权限: 。
  6. 改密码:update user set password=password('root123') where user='root';(别忘了最后加分号) 。
  7. 刷新权限(必须步骤): 
  8. 退出quit当前cmd,并且关闭2中的DOS窗口
  9. 使用用户名root,新密码root123在4中DOS窗口登录。
(window.slotbydup=window.slotbydup || []).push({
id: '2467140',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467141',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467143',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467148',
container: s,
size: '1000,90',
display: 'inlay-fix'您所在的位置: &
MySQL修改root密码并不难
MySQL修改root密码并不难
今天我们主要向大家介绍的是MySQL 修改 root 密码命令实际应用的介绍,以下就是文章的详细内容介绍,望大家借鉴。
以下的文章主要介绍修改 root 密码命令实际应用的介绍,其中包括对更改MySQL数据库的root 管理员密码以及MySQL 数据库修改root 密码命令等相关内容的介绍,希望会给你带来一些帮助在此方面。
一、请问在win2K命令提示符下怎样更改MySQL的root管理员密码?
MySQL&-u&root&-p &Enter&password:&****** &MySQL&use&MySQL; &MySQL&update&user&set&passwordpassword=password('new_password')&where&user='root';&
通过这种方法就可以直接MySQL 修改密码了。至于在CMD下能否登陆MySQL,就要在Windows环境变量PATH中添加&C:\Program Files\MySQL\MySQL Server 5.0\&(请改为你自己的安装路径)了。
二、MySQL 修改root密码命令
cmd下切换到 MySQL 安装目录
d:/MySQL/bin
前提:MySQL用户root密码为空.
输入 MySQL -u root MySQL
MySQL& 状态下输入 update user set password=password('新密码') where user='root';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 2 Changed: 0 Warnings: 0
MySQL& 状态下输入 FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
MySQL& 状态下输入 quit
注意每个命令后都要加上一个分号 &;&
MySQL 才开始执行该行命令
而第二个指令会让已载入记忆体的 MySQL 系统资料库更新
重起 MySQL .
在更新 root 密码後,日後要与 MySQL 连线的方法为:
MySQL -uroot -p新密码
忘记MySQL 的root 密码:
先确认已经杀掉MySQLd 进程了,然后执行这个
/usr/bin/safe_MySQLd --skip-grant-tables &
再这样登录
MySQL -h 192.168.1.2 -u root
上边的192.168.1.2 是cloud 的MySQLd 运行机器,你换成自己的,这样登录上
去,就可以MySQL 修改密码了。
1.MySQL -h hostname &u root 命令登录到MySQLd server 用grant 命令改变口令:
Grant all on *.* to root indentified by &111111&
2. MySQLadmin -u 用户名-p 旧密码password 新密码
例1:给root 加个密码ab12。首先在DOS 下进入目录MySQLbin,然后键入
MySQLadmin -uroot password ab12
注:因为开始时root 没有密码,所以-p 旧密码一项就可以省略了。
2、例2:再将root 的密码改为djg345。
MySQLadmin &u root -pab12 password djg345 (注意-p 不要和后面的密码分
开写,要写在一起)
use&MySQL;&update&user&set&passwordpassword&=password('yourpass')&where&user='r& &oot'&&
4. 载入权限表: `MySQLadmin -h hostname flush-privileges' ,或者使
用SQL 命令`FLUSH PRIVILEGES'。(当然,在这里,你也可以重启MySQLd。)
MySQL 的建库,添加数据方法:
mysqi&&u&root& &MySQLcreate&database&& &MySQLsource&1.txt& &MySQLload&data&local&infile&&2.txt&&into&table&&&
1.txt 内容:
CREATE&TABLE&board&(& &boardid&int(11)&NOT&NULL&auto_increment,& &boardname&char(255),& &PRIMARY&KEY&(boardid)& &);&&
2.txt 内容:
1 lk(Tab 键分开)
导出database:
#MySQLdump &opt ttt &uroot &p111111 & 111.sql
导入database
1. #MySQL &u root &p111111 ttt & 111.sql
2. MySQL&source 111.
导出的多个database:#MySQLdump &-databases ttt1 ttt2 ttt3 &uroot &p111111
导出所有database:#MySQLdump &-all-databases &uroot &p111111 & 111.sql
补一下不知道root密码情况下MySQL 修改root密码
MySQLd启动的时候加上&skip-grant-tables,然后马上修改密码,修改后去掉&skip-grant-tables,然后就OK了。
【编辑推荐】
【责任编辑: TEL:(010)】
关于的更多文章
MySQL是完全网络化的跨平台关系型数据库系统,同时是具有客户机/
数据库产品
数据库综合
数据库新闻
维基百科将切换到另外一款开源数据库MariaDB
讲师: 38人学习过讲师: 7人学习过讲师: 55人学习过
你的SQL Server代码安全吗?请你与我一起跟随作者来探
为什么会发生死锁?如何利用SQL Server Profiler分析
Oracle集群,也称Oracle RAC,称为“真正应用集群”。
本书虽然是《网管员必读―网络应用》的改版,但它绝不是简单的修改,而是完完全全的重写,内容更实用、更专业。全书共9章,13个
51CTO旗下网站编程开发子分类推荐这篇日记的豆列
······}

我要回帖

更多关于 忘记mysql root密码 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信