我一直在尝试重置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
- 停止 Mysql 服务器
sudo/etc/init.d/mysql 停止
- 为避免错误,UNIX 套接字文件的 mysqld_safe 目录 '/var/run/mysqld' 不存在,请运行以下命令:
sudo mkdir -p/var/run/mysqld sudo chown mysql:mysql/var/run/mysqld
- 以安全模式启动mysql:
sudo mysqld_safe --skip-grant-tables &
- 登录 Mysql 并将密码更改为“root123”:
在 5.7 版本中,密码列被重命名为 authentication_string。
mysql -uroot mysql>使用mysql; mysql>更新用户集 authentication_string=password('root123') where user='root';
- 如果你得到错误::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>刷新权限; 退出;
- 停止和启动 mysql 服务器
sudo/etc/init.d/mysql 停止 sudo/etc/init.d/mysql 启动
- 使用新密码登录
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/