Home >Database >Mysql Tutorial >mysql创建新用户相关语句_MySQL

mysql创建新用户相关语句_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-01 13:36:291276browse

bitsCN.com

mysql创建新用户相关语句

 

首先以 root权限登录 

创建用户 

Sql代码  

create user username identified by 'password';  

该用户可在任意地方登录数据库 

 

Sql代码  

create user username@ip identified by 'password';  

 

限定登录主机 

 

给新用户授权 

Sql代码  

grant privileges on database.table to user@ip identified by "password"  

 

   select, insert, update, delete, all 

 

通过这种方法,对数据库的修改立即写入内存,即时生效,无须重启服务器 

 

但是以新增用户登录后,提示 

ERROR 1045 (28000): Access denied for user 'database'@'localhost' (using password: YES) 

需要删除匿名用户 

 

以root身份登录 

Sql代码  

use mysql  

select host, user from mysql;  

 

发现存在若干个user项为空的记录,删除之 

Sql代码  

delete from mysql where user="";  

 

 

操作仍然涉及权限,但非grant操作未即时写入内存,或者重启,或者

Sql代码  

flush privileges;  

 

bitsCN.com
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