mysql手工新增root使用者

myownstars發表於2011-02-12

Mysqlroot使用者是可以手工新增的,也可以透過grant賦權新增

 

1

mysql> select host,user from user;

+-----------------------+----------------+

| host                  | user           |

+-----------------------+----------------+

| %                     | market         |

| %                     | marketuser     |

| %                     | orderuser      |

| %                     | qryorders_user |

| %                     | yhd_mobile     |

| %                     | yhd_user       |

| 10.1.0.99             | monitor        |

| 127.0.0.1             | root           |

| localhost             | root           |

| localhost.localdomain | root           |

+-----------------------+----------------+

10 rows in set (0.00 sec)

 

mysql> insert into user(host,user,password) values('%','root',password('my_passsword'));

Query OK, 1 row affected, 3 warnings (0.00 sec)

 

mysql> select host,user from user;

+-----------------------+----------------+

| host                  | user           |

+-----------------------+----------------+

| %                     | market         |

| %                     | marketuser     |

| %                     | orderuser      |

| %                     | qryorders_user |

| %                     | root           |

| %                     | yhd_mobile     |

| %                     | yhd_user       |

| 10.1.0.99             | monitor        |

| 127.0.0.1             | root           |

| localhost             | root           |

| localhost.localdomain | root           |

+-----------------------+----------------+

 

2

mysql> select host,user from user;

+-----------------------+----------------+

| host                  | user           |

+-----------------------+----------------+

| %                     | market         |

| %                     | marketuser     |

| %                     | orderuser      |

| %                     | qryorders_user |

| %                     | yhd_mobile     |

| %                     | yhd_user       |

| 10.1.0.99             | monitor        |

| 127.0.0.1             | root           |

| localhost             | root           |

| localhost.localdomain | root           |

+-----------------------+----------------+

10 rows in set (0.00 sec)

 

mysql> grant all privileges on *.* to root@"%";

Query OK, 0 rows affected (0.00 sec)

 

mysql> select host,user from user;

+-----------------------+----------------+

| host                  | user           |

+-----------------------+----------------+

| %                     | market         |

| %                     | marketuser     |

| %                     | orderuser      |

| %                     | qryorders_user |

| %                     | root           |

| %                     | yhd_mobile     |

| %                     | yhd_user       |

| 10.1.0.99             | monitor        |

| 127.0.0.1             | root           |

| localhost             | root           |

| localhost.localdomain | root           |

+-----------------------+----------------+

11 rows in set (0.00 sec)

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/15480802/viewspace-687057/,如需轉載,請註明出處,否則將追究法律責任。

相關文章