How to retrieve the root password of MySQL database

From , 3 Years ago, written in SQL, viewed 94 times.
URL https://pastebin.vip/view/e904831f
  1. linux下忘记了mysql的root用户密码解决办法:
  2.   一、以系统的root用户(什么,你的系统的root用户密码也忘了。那只好看我另外一篇linux下忘记root用户的解决办法了先解决这个问题)登陆系统,进入终端
  3.   [root@localhost /]#
  4.  
  5.   二、杀掉mysql进程
  6.   方法1[root@localhost /]#killall mysqld
  7.   方法2[root@localhost /]#ps -aux  //查看所有进程,找到mysql进程的pid
  8.   然后
  9.   [root@localhost /]#kill pid   //pid是mysql的进程号
  10.  
  11.   三、用--skip-grant-tables参数启动mysqld
  12.   [root@localhost /]#/usr/LOCAL/mysql/bin/mysqld_safe --skip-grant-tables&  
  13.   // 其中/usr..../bin是我的mysql安装目录
  14.   [root@localhost /]#/usr/LOCAL/mysql/bin/mysql  //进入mysql
  15.   mysql> USE mysql   //切换到mysql DATABASE
  16.   mysql> UPDATE USER SET password=password('123456') WHERE USER='root';
  17.   //将root密码该为123456
  18.  
  19.   四、注意事项
  20.   The FULL command TO LOAD MySQL LIKE this IS:
  21.   mysqld_safe --skip-grant-tables --autoclose
  22.   (Editor's Note: Our technical reviewer found that he had to launch the mysqld_safe command
  23.   without the '--autoclose' flag, otherwise the daemon never started.)
  24.   这是国外网站说的,我没用autoclosa也成功了
  25.   但是我在执行/usr/LOCAL/mysql/bin/mysqld_safe --skip-grant-tables&即出现错误提示:
  26.   ./mysqld_safe
  27.   starting mysqld daemon WITH DATABASES FROM /usr/LOCAL/var
  28.   STOPPING server FROM pid file /usr/LOCAL/var/localhost.localdomain.pid
  29.   mysqld  ended
  30.   然后进入/usr/LOCAL/var/
  31.   vi ./localhost.localdomain.err 内容如下:
  32.   050410 04:02:59 mysqld started
  33.   050410 4:03:00 InnoDB:Operating system error NUMBER 13 IN a file operation.
  34.   InnoDB:The error means mysqld does NOT have the access rights TO
  35.   InnoDB:the directory.
  36.   InnoDB:File name ./ibdata1
  37.   InnoDB:File operation CALL:'create'.
  38.   InnoDB:Cannot continue operation.
  39.   050410 04:03:00 mysqld ended
  40.   怀疑是./var目录的访问权限,故如下操作:
  41.   chmod 777 ./var
  42.   然后重新执行后台,仍出以上错误,但在localhost.localdomain.err文件中的错误信息已改为找不到一个叫做
  43.   help.*的文件了(这个文件名我记不得了)
  44.   这是因为我的mysql安装目录的读写权限是这样造成的
  45.   mysql安装目录属于用户root,但是群组是mysql的
  46.   把群组也改为root即可。
  47. //SQL/6179

Reply to "How to retrieve the root password of MySQL database"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website