• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • MsSql
  • Mysql
  • oracle
  • MariaDB
  • DB2
  • SQLite
  • PostgreSQL
  • MongoDB
  • Redis
  • Access
  • 数据库其它
  • sybase
  • HBase
您的位置:首页 > 数据库 >Mysql > MySQL之——忘记Root密码如何操作

MySQL之——忘记Root密码如何操作

作者:匿名 字体:[增加 减小] 来源:互联网 时间:2018-12-05

匿名通过本文主要向大家介绍了MySQL,Root密码等相关知识,希望本文的分享对您有所帮助
1、在命令行输入命令

root@centos64 mysql]# /usr/bin/mysqld_safe --skip-grant-tables&

2. 再启一个终端执行下面的一系列命令:

[root@centos64 proc]# mysql  
Welcome to the MySQL monitor.  Commands end with ; or \g.  
Your MySQL connection id is 1  
Server version: 5.6.13 MySQL Community Server (GPL)  
  
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> UPDATE user SET password=password('admin') WHERE user='root';  
ERROR 1046 (3D000): No database selected  
mysql> show databases ;  
+--------------------+  
| Database           |  
+--------------------+  
| information_schema |  
| mysql              |  
| performance_schema |  
| test               |  
+--------------------+  
4 rows in set (0.06 sec)  
  
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  
mysql> UPDATE user SET password=password('admin') WHERE user='root';  
Query OK, 4 rows affected (0.04 sec)  
Rows matched: 4  Changed: 4  Warnings: 0  
  
mysql> flush privileges;   也可以不用。  
  
mysql> exit  
Bye

注意,就是有可能,user表中根本就没有root这个用户。
如果没有此用户,用:

mysql> insert into mysql.user(Host,User,Password,ssl_cipher,x509_issuer,x509_subject) values("localhost","root",password("admin"),"","","");  
Query OK, 1 row affected (0.10 sec)

3.授权。 给所有的权限

mysql> grant all privileges on *.* to  'root'@'localhost' identified by 'admin' ;  
Query OK, 0 rows affected (0.06 sec)  
mysql> flush privileges;

再以正常的方式启动即可。

以上就是MySQL之——忘记Root密码如何操作的内容,更多相关内容请关注微课江湖()!

分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

  • 分享下mysql各个主要版本之间的差异
  • MySQL essential版本和普通版本有什么区别?
  • redhat 5.4下安装MYSQL全过程
  • 如何用SQL命令查看Mysql数据库大小
  • 解析mysql中如何获得数据库的大小
  • 解析mysql修改为utf8后仍然有乱码的问题
  • 5个常用的MySQL数据库管理工具详细介绍
  • 解析在MySQL里创建外键时ERROR 1005的解决办法
  • 解析远程连接管理其他机器上的MYSQL数据库
  • mysql 精简过程(删除一些文件)

相关文章

  • 2018-12-05mysql 协议的删除DB命令包及解析
  • 2018-12-05spring事务隔离级别、传播行为以及spring+mybatis+atomikos实现分布式事务管理
  • 2018-12-0510分钟学会理解和解决MySQL乱码问题
  • 2018-12-05两种lnmp重置mysql数据库root密码的方法
  • 2018-12-05SQL语句查询是否为空 =null及null
  • 2018-12-05sqlserver 存储过程分页(按多条件排序)
  • 2018-12-05网上提供的最简便的MySql数据库备份的方法
  • 2018-12-05Mysql中关于权限设置详解
  • 2018-12-05Mysql系列(十)Mysql条件判断
  • 2018-12-05Server2005中更改sa的用户名的多种方法

文章分类

  • MsSql
  • Mysql
  • oracle
  • MariaDB
  • DB2
  • SQLite
  • PostgreSQL
  • MongoDB
  • Redis
  • Access
  • 数据库其它
  • sybase
  • HBase

最近更新的内容

    • MySQL复制的概述、安装、故障、技巧、工具(火丁分享)
    • 关于节点配置的详细介绍
    • 总结和Mysql相关的知识
    • PDO连接数据库及DSN详解
    • 关于数值函数的10篇文章推荐
    • 远程连接局域网内的sql server 无法连接 错误与解决方法
    • 关于mysql的最新安全漏洞问题处理办法:
    • SQL批量插入数据几种方案的性能详细对比
    • SQL Server重温 事务
    • 在win7上安装oracle 10g配置文件更改

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有