zoukankan      html  css  js  c++  java
  • mysql 忘记密码登录

    mysql 初次安装完成后 用户root 密码是空,如果用空密码登不进去,可以使用下面的方法

    以下是详细修改密码步骤: 第一步、 登录服务器,找到 my.cnf 文件,通常该文件路径为
    /etc/my.cnf ,如果不在,可以用 find / -name my.cnf 命令查找一下。 第二步、 编辑 my.cnf 文件 ,在[mysqld]下面加上 skip-grant-tables。 这句话会让mysql数据库登录时跳过密码验证,也就是说,root登录时,输入什么密码都能进入数据库管理。 【示例】 [mysqld] skip-grant-tables datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock 第三步、 重启mysql,命令:service mysqld restart 【反馈】 # /etc/init.d/mysqld restart Stopping MySQL: [ OK ] Starting MySQL: [ OK ] 第四步、 任意密码登录mysql数据库,使用命令:use mysql; 打开mysql数据库。 【反馈】 Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 3 to server version: 3.23.56 Type 'help;' or 'h' for help. Type 'c' to clear the buffer. 第五步、 使用命令:select user,host,password from user; 查询数据库用户信息,可以看到用户名和对应的被加密后的密码。 第六步、 使用命令:UPDATE user SET Password = password ( '你要修改的密码' ) WHERE User = 'root' ; 为root修改为你要的新密码。 【反馈】 Query OK, 0 rows affected (0.00 sec) Rows matched: 2 Changed: 0 Warnings: 0 第七步、 退出mysql,命令:quit; 【反馈】 mysql> quit Bye 第八步、 vi编辑 my.cnf 文件,将第二步添加的 skip-grant-tables 删除,或在前面加上#进行注释。 第九步、 重启mysql,命令:service mysqld restart 【反馈】 # /etc/init.d/mysqld restart Stopping MySQL: [ OK ] Starting MySQL: [ OK ]

    源自 https://my.oschina.net/chinacion/blog/745262

  • 相关阅读:
    Windows Internals学习笔记(八)IO系统
    FPGA相关术语(一)
    Bilinear Filter
    总线与接口
    GPIO相关知识
    .NET IL学习笔记(一)
    Windows Internals学习笔记(七)Image Loader
    Windows Internals学习笔记(五)Synchronization
    struts2官方 中文教程 系列五:处理表单
    struts2官方 中文教程 系列四:Action
  • 原文地址:https://www.cnblogs.com/suxiaolong/p/6517600.html
Copyright © 2011-2022 走看看