您好,欢迎访问一九零五行业门户网

mysql创建新用户相关语句_MySQL

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
其它类似信息

推荐信息