MySQL 忘记密码后的重置操作
<font face="Tahoma, &quot">一、修改配置文件方式</font><br /><font face="Tahoma, &quot"> 1、关闭 MySQL </font><br /><font face="Tahoma, &quot"> linux:</font><br /><font face="Tahoma, &quot"> 1)service mysqld stop</font><br /><font face="Tahoma, &quot"> 2)/usr/local/mysql/support-files/mysql.server stop</font><br /><font face="Tahoma, &quot"> Windows:</font><br /><font face="Tahoma, &quot"> 1) 命令提示符下执行 net stop mysql</font><br /><font face="Tahoma, &quot"> 2)计算机右键管理 -> 服务 ,找到mysql服务,停止此服务</font><br /><font face="Tahoma, &quot"> 2、修改配置文件</font><br /><font face="Tahoma, &quot"> linux下配置文件为my.cnf ,windows下配置文件为my.ini,在下添加</font><br /><font face="Tahoma, &quot"> skip-grant</font><br /><font face="Tahoma, &quot"> 3、重启MySQL</font><br /><font face="Tahoma, &quot"> linux:</font><br /><font face="Tahoma, &quot"> 1)service mysqld start</font><br /><font face="Tahoma, &quot"> 2)/usr/local/mysql/support-files/mysql.server start</font><br /><font face="Tahoma, &quot"> Windows:</font><br /><font face="Tahoma, &quot"> 1) 命令提示符下执行 net start mysql</font><br /><font face="Tahoma, &quot"> 2)计算机右键管理 -> 服务 ,找到mysql服务,启动此服务</font><br /><font face="Tahoma, &quot"> 4、进入MySQL</font><br /><font face="Tahoma, &quot"> Linux:</font><br /><font face="Tahoma, &quot"> /usr/local/mysql/bin/mysql -u root -p 进入mysql</font><br /><font face="Tahoma, &quot"> windows:</font><br /><font face="Tahoma, &quot"> D:/mysql/mysql -u root -p 进入mysql,其中,D:/mysql为mysql的安装目录</font><br /><font face="Tahoma, &quot"> </font><br /><font face="Tahoma, &quot"> 5、更改密码</font><br /><font face="Tahoma, &quot"> 执行下面语句</font><br /><font face="Tahoma, &quot"> use mysql;</font><br /><font face="Tahoma, &quot"> UPDATE user SET Password=password("XXX") WHERE User="root"; 其中,XXX是你要设置的密码</font><br /><font face="Tahoma, &quot"> flush privileges;</font><br /><font face="Tahoma, &quot"> exit;</font><br /><font face="Tahoma, &quot"> 6、去掉配置文件中的 skip-grant</font><br /><font face="Tahoma, &quot"> 7、重启 MySQL</font><br /><font face="Tahoma, &quot"> </font><br /><font face="Tahoma, &quot">二、命令方式(针对linux)</font><br /><font face="Tahoma, &quot"> 1、关闭 MySQL</font><br /><font face="Tahoma, &quot"> 1)service mysqld stop</font><br /><font face="Tahoma, &quot"> 2)/usr/local/mysql/support-files/mysql.server stop</font><br /><font face="Tahoma, &quot"> 2、执行下面命令</font><br /><font face="Tahoma, &quot"> /usr/local/mysql/bin/mysqld_safe --skip-grant</font><br /><font face="Tahoma, &quot"> 3、进入 MySQL </font><br /><font face="Tahoma, &quot"> /usr/local/mysql/bin/mysql -u root -p 进入mysql</font><br /><font face="Tahoma, &quot"> 4、更改密码</font><br /><font face="Tahoma, &quot"> 执行下面语句</font><br /><font face="Tahoma, &quot"> use mysql;</font><br /><font face="Tahoma, &quot"> UPDATE user SET Password=password("XXX") WHERE User="root"; 其中,XXX是你要设置的密码</font><br /><font face="Tahoma, &quot"> flush privileges;</font><br /><font face="Tahoma, &quot"> exit;</font><br /><font face="Tahoma, &quot"> 5、重启 MySQL</font><br />Tahoma<em>, </em>quot<em>, </em>mysql<em>, </em>MySQL
頁:
[1]