MySQL忘记密码后重置密码

Windows:
1.用系统管理员登陆系统。
2.停止MySQL的服务。 打开命令行窗口:        Net stop mysql
3.进入命令窗口,然后进入MySQL的安装目录,比如我的安装目录是c:mysql,进入C:mysqlbin
4.跳过权限检查启动MySQL,
c:mysqlbin>mysqld-nt --skip-grant-tables
5.重新打开一个窗口,进入c:mysqlbin目录,设置root的新密码
c:mysqlbin>mysqladmin -u root flush-privileges password "newpassword"
c:mysqlbin>mysqladmin -u root -p shutdown
将newpassword替换为你要用的root的密码,第二个命令会提示你输入新密码,重复第一个命令输入的密码。
6.停止MySQL Server,用正常模式启动Mysql ,打开命令行窗口: Net start mysql
7.你可以用新的密码链接到Mysql了。

Unix&Linux:
1.用root或者运行mysqld的用户登录系统
2.结束mysql服务

    sudo /etc/init.d/mysql stop
3.使用--skip-grant-tables参数启动MySQL Server
    mysqld_safe --skip-grant-tables
4.为root@localhost设置新密码
    mysqladmin -u root flush-privileges password "newpassword"

5.重启MySQL Server

你可能感兴趣的:(windows,忘记密码,password,系统管理员,用户登录)