现在的位置: 首页 > 综合 > 正文

在不知道MySQL帐号密码的情况下创建帐号并获得权限

2013年05月03日 ⁄ 综合 ⁄ 共 899字 ⁄ 字号 评论关闭

在不知道MySQL帐号密码的情况下创建帐号并获得权限

 

1、 知道root帐号的情况下登录mysql系统

mysql -h10.0.0.1 -uroot -p123 

2、 不知道帐号可以

a)         在一个cmd下执行mysqld-nt --skip-grant-tables,然后另外一个cmd下直接运行mysql即可直接登录。

b)         修改my.ini跳过mysql验证。

[mysqld]

skip-grant-tables

# The TCP/IP Port the MySQL Server will listen on

port=3306

3、 成功登录后可不修改用户密码登录其系统

a)         保存原始密码

Mysql>select host,user,password from mysql.user; --记录password的加密字串,如AAAA

b)         修改用户密码

Update mysql.user set password=”你知道密码的加密字串” –修改后可登录用户系统

c)         还原用户原始密码

Update mysql.user set password=”AAAA”

d)         若用户权限较高,你可以在步骤c之前用步骤b修改的密码登录系统创高级帐号或授权。

mysql>use mysql;
mysql>update user set password=password('新密码') WHERE User='root'; 

mysql>flush privileges;

mysqladmin -u用户名 -p旧密码 password 新密码

4、 添加新用户

grant select,insert,update,delete on *.* to test1@"%" Identified by "abc"; 

grant select,insert,update,delete on mydb.* to test2@localhost identified by "abc"; 

grant select,insert,update,delete on mydb.* to test2@localhost identified by ""; 

5、 OK,收工。

抱歉!评论已关闭.