Home  >  Article  >  Database  >  增加MySQL用户

增加MySQL用户

WBOY
WBOYOriginal
2016-06-07 16:53:29961browse

格式:grant select on 数据库.* to 用户名@登录主机 identified by quot;密码quot;例1、增加一个用户user_britepic密码为

  格式:grant select on 数据库.* to 用户名@登录主机 identified by "密码"

例1、增加一个用户user_britepic密码为linuxidc,让他可以在任何主机上登录,并对所有数据库有查询、插入、修改、删除的权限。首先用以root用户连入MySQL,然后键入以下命令:

  mysql> grant select,insert,update,delete on *.* to user_britepic@"%" Identified by "linuxidc";

例1增加的用户是十分危险的,如果知道了user_britepic的密码,那么他就可以在网上的任何一台电脑上登录你的MySQL数据库并对你的数据为所欲为了,解决办法见例2。

  例2、增加一个用户user_avnads密码为linuxidc,让此用户只可以在localhost上登录,并可以对数据库aaa进行查询、插入、修改、删除的操作(localhost指本地主机,即MySQL数据库所在的那台主机),这样用户即使用知道user_avnads的密码,他也无法从网上直接访问数据库,只能通过MYSQL主机来操作aaa库。

  mysql>grant select,insert,update,delete on aaa.* to user_avnads@localhost identified by "linuxidc";

  用新增的用户如果登录不了MySQL,在登录时用如下命令:

  mysql -u user_britepic -p -h 192.168.113.50 (-h后跟的是要登录主机的ip地址)

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn