mysql - 如何重置忘记的 MySQL root 密码?

标签 mysql

我一直在尝试重置MySQL的root密码。

我习惯了两种重置方法。但是我没有得到它。

已完成以下步骤,但对我不起作用:

方法一:

1) Stopped running of MySQL services and created a mysql-init.txt file. mysql-init.txt contains:

USE mysql;

UPDATE mysql.user SET Password=PASSWORD('vikash') WHERE User = 'root';

FLUSH PRIVILEGES;

2) I have opened the command prompt and i typed the following:

C:\Program Files\MySQL\MySQL Server 5.6\bin>mysqld.exe --defaults-file="my.ini" --init-file="C:\\Users\\user-name\\Desktop\\mysql-init.txt" --console

我得到的ERROR如下:

Could not open required defaults file: C:\Program Files\MySQL\MySQL Server 5.6\b in\my.ini

默认处理中的 fatal error 。程序中止

方法二:

I simply opened the command prompt and typed as follows:

C:\Program Files\MySQL\MySQL Server 5.6\bin>mysqladmin -uroot -psample password
vikash

I got the error as:

Warning: Using a password on the command line interface can be insecure.
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'

请帮我重设密码...

最佳答案

以下是当我们忘记root用户密码或忘记找回安装时提供的密码时,重置root用户密码的过程。

操作系统 - Ubuntu 16.04

MySQL - 5.7

  1. 停止 Mysql 服务器 sudo/etc/init.d/mysql 停止
  2. 为避免错误,UNIX 套接字文件的 mysqld_safe 目录 '/var/run/mysqld' 不存在,请运行以下命令: sudo mkdir -p/var/run/mysqld sudo chown mysql:mysql/var/run/mysqld
  3. 以安全模式启动mysql: sudo mysqld_safe --skip-grant-tables &
  4. 登录 Mysql 并将密码更改为“root123”: 在 5.7 版本中,密码列被重命名为 authentication_string。 mysql -uroot mysql>使用mysql; mysql>更新用户集 authentication_string=password('root123') where user='root';
  5. 如果你得到错误::MySQL fails on: mysql “ERROR 1524 (HY000): Plugin 'auth_socket' is not loaded” 然后运行下面的命令然后运行第四步。 mysql>update user set plugin="mysql_native_password"where User='root'; mysql>刷新权限; 退出;
  6. 停止和启动 mysql 服务器 sudo/etc/init.d/mysql 停止 sudo/etc/init.d/mysql 启动
  7. 使用新密码登录 mysql -uroot -proot123

PFB,供引用的 URL。

https://support.rackspace.com/how-to/mysql-resetting-a-lost-mysql-root-password/ mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists MySQL user DB does not have password columns - Installing MySQL on OSX MySQL fails on: mysql "ERROR 1524 (HY000): Plugin 'auth_socket' is not loaded"

关于mysql - 如何重置忘记的 MySQL root 密码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24489976/

相关文章:

mysql - 如何在 WHERE 子句中正确编写此 IF 条件 codeigniter

php - 如何强制用户下载(另存为对话框)刚刚生成的文件?

mysql - 如何从 mysql 表中读取动态变量名称和值,以便可以在 SOAPUI 请求中使用它们

php - Paypal IPN 与 MySQL 集成

php 在 null 上调用成员函数 query()

MySQL 5 更新后触发器不起作用

mysql - 如何使用批处理文件对 agilefant(我的 sql 数据库)进行数据库备份

mysql - 迁移异常: alter table --> Column already exists: 1060 Duplicate column name

mysql - 如何通过 openquery 和链接服务器在 VS 中使用 MySQL 数据为 SSRS 2008 报告创建数据集

php - laravel - 给定可变用户输入生成组合