MYSQL忘记ROOT密码后? |
修改MySQL的登录设置: 1.取消权限管理 编辑 /mysql5.1/my.ini 在[mysqld]的段中加上一句:skip-grant-tables 例如: [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock skip-name-resolve skip-grant-tables 目的是为了: 跳过MySQL的访问控制,任何人都可以在控制台以管理员的身份进入MySQL数据库。 需要注意的是在修改完密码以后要把MySQL服务器停掉重新启动才会生效 重启mysql服务! 2.登陆修改root用户密码 mysql> USE mysql ; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> UPDATE user SET Password = password ( ‘new-password’ ) WHERE User = ‘root’ ; Query OK, 0 rows affected (0.00 sec) Rows matched: 2 Changed: 0 Warnings: 0 mysql> flush privileges ; Query OK, 0 rows affected (0.01 sec) mysql> quit 3.增加权限管理 按照第1步方案[mysqld]的段中删除:skip-grant-tables PS: 可能出现的问题: 1.Host 'localhost' is not allowed to connect to this MySQL server ? 由于是本地测试,可用就行,故没解决这个问题! |
MYSQL忘记ROOT密码后?
最新推荐文章于 2023-09-05 18:59:40 发布