您好,欢迎来到易妖游戏网。
搜索
您的当前位置:首页mysql创建新用户相关语句_MySQL

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

Copyright © 2019- vipyiyao.com 版权所有 湘ICP备2023022495号-8

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务