《MYSQL数据库不重启Mysql修改root密码的方法》要点:
本文介绍了MYSQL数据库不重启Mysql修改root密码的方法,希望对您有用。如果有疑问,可以联系我们。
一、一般忘记密码的解决办法,需要重启Mysql
1、skip-grant-tables
我们常用的方法是使用skip-grant-tables选项,mysqld server启动之后并不使用权限系统(privilege system).用户不需要任何账号、不受任何限制的访问数据库中所有数据.为了安全起见,通常加上 skip-networking ,mysqld不侦听任何TCP/IP连接请求.操作过程如下,
1)修改my.cnf配置文件,在mysqld选项中添加skip-grant-tables和skip-networking.
2)再重启mysqld server.
3)通过sql语句修改mysql.user表中存储密码.执行flush privileges,重新启用mysql权限系统.
MYSQL实例
二、不重启mysqld的方法MYSQL实例
1、首先得有一个可以拥有修改权限的mysql数据库账号,当前的mysql实例账号(较低权限的账号,比如可以修改test数据库)或者其他相同版本实例的账号.把data/mysql目录下面的user表相关的文件复制到data/test目录下面.
MYSQL实例
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.MYSQL实例
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.MYSQL实例
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MYSQL实例
mysql> use test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -AMYSQL实例
Database changed
mysql> update user set password=password('yayun') where user='root';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 5 Changed: 0 Warnings: 0MYSQL实例
mysql>MYSQL实例
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.MYSQL实例
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.MYSQL实例
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MYSQL实例
mysql>MYSQL实例
MYSQL实例
转载请注明本页网址:
http://www.vephp.com/jiaocheng/1633.html