今天mysql使用root无法在远程登录,只能在服务器使用localhost登录。而且修改了权限后忘记了刷新权限,就只有重启mysql服务就好了
原文:
http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html
On Windows, use the following procedure to reset the password for all MySQL root accounts:
Log on to your system as Administrator.
Stop the MySQL server if it is running. For a server that is running as a Windows service, go to the Services manager: From the Start menu, select Control Panel, then Administrative Tools, then Services. Find the MySQL service in the list and stop it.
If your server is not running as a service, you may need to use the Task Manager to force it to stop.
Create a text file containing the following statements. Replace the password with the password that you want to use.
UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
FLUSH PRIVILEGES;
Write the UPDATE and FLUSH statements each on a single line. The UPDATE statement resets the password for all root accounts, and the FLUSH statement tells the server to reload the grant tables into memory so that it notices the password change.
Save the file. For this example, the file will be named C:\mysql-init.txt.
Open a console window to get to the command prompt: From the Start menu, select Run, then enter cmd as the command to be run.
Start the MySQL server with the special --init-file option (notice that the backslash in the option value is doubled):
C:\> C:\mysql\bin\mysqld-nt --init-file=C:\\mysql-init.txt
If you installed MySQL to a location other than C:\mysql, adjust the command accordingly.
The server executes the contents of the file named by the --init-file option at startup, changing each root account password.
You can also add the --console option to the command if you want server output to appear in the console window rather than in a log file.
If you installed MySQL using the MySQL Installation Wizard, you may need to specify a --defaults-file option:
C:\> "C:\Program Files\MySQL\MySQL Server 5.0\bin\mysqld-nt.exe"
--defaults-file="C:\\Program Files\\MySQL\\MySQL Server 5.0\\my.ini"
--init-file=C:\\mysql-init.txt
The appropriate --defaults-file setting can be found using the Services Manager: From the Start menu, select Control Panel, then Administrative Tools, then Services. Find the MySQL service in the list, right-click it, and choose the Properties option. The Path to executable field contains the --defaults-file setting.
After the server has started successfully, delete C:\mysql-init.txt.
You should now be able to connect to the MySQL server as root using the new password. Stop the MySQL server, then restart it in normal mode again. If you run the server as a service, start it from the Windows Services window. If you start the server manually, use whatever command you normally use.
分享到:
相关推荐
本文介绍了MySQL修改root密码的多种方法,忘记密码时,管理员可以在服务器上修改ROOT密码,防止忘记密码导致数据无法导出或使用工具连接数据库。
修改Mysql的root密码方法,比较好用。希望能方便大家。
mysql修改root密码的四种方法 本文以windows为例为大家详细介绍下MySQL修改root密码的4种方法,大家可以可以根据的自己的情况自由选择,希望对大家有所帮助
修改Mysql的root用户密码 修改Mysql的root用户密码 修改Mysql的root用户密码
新装MySQL不知道密码,忘记MySQL密码,都可以安装该方法改过来,在Ubuntu和CentOS上用过多次。
主要介绍了MySQL修改root密码的4种方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
整理了以下四种在MySQL中修改root密码的方法
比较快捷的修改MySQL的根密码,搭建MySQL数据库运行环境,节约操作数据的时间。
centeos5.5下编译安装MYSQL以及安装过程中遇到的问题解决方法,修改root密码
我们在使用Linux下搭建数据库往往会设置很繁琐忘记密码 接下教大家如何不需要密码修改
本文给大家分享了三种方法来解决mysql修改root密码的方法,非常不错,具有参考借鉴价值,需要的朋友参考下吧
MySQL修改root密码的4种方法(以windows为例).docx
一、请问在win2K命令提示符下怎样更改mysql的root管理员密码? >mysql -u root -p Enter password: ****** mysql> use mysql; mysql> update user set password=password(‘new_password’) where user=’root’; ...
MySQL是一个关系型数据库管理系统...这里以修改root密码为例,操作系统为windows。 先要声明一点,大部分情况下,修改MySQL是需要有mysql里的root权限的, 所以一般用户无法更改密码,除非请求管理员。 方法1 :用SET
mysql给root开启远程访问权限,修改root密码
修改mysql root用户密码 修改mysql root用户密码 修改mysql root用户密码
Win10 X64 系统,安装MySQL,一手资料。 这个方案是在很多次失败中总结的,一定要认真看过程。
主要介绍了MySQL 如何修改root用户的密码,帮助大家更好的使用MySQL,不用担心忘记密码,感兴趣的朋友可以了解下
例子:mysql> set password for root@localhost = password(‘123’); mysql5.7和mysql8.0以上都可以用 方法2:用mysqladmin 格式:mysqladmin -u用户名 -p password 新密码 例子:mysqladmin -uroot -p ...