欢迎投稿

今日深度:

MySQL新增用户以及数据库访问授权,mysql新增

MySQL新增用户以及数据库访问授权,mysql新增


# mysql -u root -p
# 允许本地 IP 访问 localhost, 127.0.0.1
# insert into mysql.user(Host,User,Password) values('localhost','zhouz',password('1234'));
# 允许外网 IP 访问
# insert into mysql.user(Host,User,Password) values('%','zhouz',password('1234'));
# 刷新授权
# flush privileges;
# 创建数据库
# create database zhouzdb DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
# 授予用户通过外网IP对于该数据库的全部权限
# grant all privileges on `zhouzdb`.* to 'zhouz'@'%' identified by '1234';
# 授予用户在本地服务器对该数据库的全部权限
# grant all privileges on `zhouzdb`.* to 'zhouz'@'localhost' identified by '1234';
# 刷新权限
# flush privileges;
# 退出 root 重新登录
# \q
# 已新帐号 zhouz 登录,由于使用的是 % 任意IP连接,所以需要指定外部访问IP
# mysql -u zhouz -h 192.168.1.168 -p
# 1234

平时难得用下 mysql 的命令行模式操作,今天弄下新建用户授权,遇到些问题在这里简单整理下

注意: 若仅开放外网访问权限,则本地是无法访问的,需要本地服务器也能访问 mysql 则要增加本地访问权限


MySQL怎授权一个自己的创建的用户比如daitest创建新数据库的权利?命令

慢慢看吧
mysql中可以给你一个用户授予如select,insert,update,delete等其中的一个或者多个权限,主要使用grant命令,用法格式为:
grant 权限 on 数据库对象 to 用户
一、grant 普通数据用户,查询、插入、更新、删除 数据库中所有表数据的权利。
grant select on testdb.* to common_user@’%’
grant insert on testdb.* to common_user@’%’
grant update on testdb.* to common_user@’%’
grant delete on testdb.* to common_user@’%’
或者,用一条 mysql 命令来替代:
grant select, insert, update, delete on testdb.* to common_user@’%’

二、grant 数据库开发人员,创建表、索引、视图、存储过程、函数。。。等权限。
grant 创建、修改、删除 mysql 数据表结构权限。
grant create on testdb.* to developer@’192.168.0.%’;
grant alter on testdb.* to developer@’192.168.0.%’;
grant drop on testdb.* to developer@’192.168.0.%’;
grant 操作 mysql 外键权限。
grant references on testdb.* to developer@’192.168.0.%’;
grant 操作 mysql 临时表权限。
grant create temporary tables on testdb.* to developer@’192.168.0.%’;
grant 操作 mysql 索引权限。
grant index on testdb.* to developer@’192.168.0.%’;
grant 操作 mysql 视图、查看视图源代码 权限。
grant create view on testdb.* to developer@’192.168.0.%’;
grant show view on testdb.* to developer@’192.168.0.%’;
grant 操作 mysql 存储过程、函数 权限。
grant create routine on testdb.* to developer@’192.168.0.%’; - now, can show procedure status
grant alter routine on testdb.* to developer@’192.168.0.%’; - now, you can drop a procedure
grant execute on testdb.* to developer@’192.168.0.%’;

三、grant 普通 dba 管理某个 mysql 数据库的权限。
grant all privileges on testdb to dba@’localhost’
其中,关键字 “privileges” 可以省略。

四、grant 高级 dba 管理 mysql 中所有数据库的权限。
grant......余下全文>>
 

MYSQL数据库怎赋予远程某个IP访问权限

你的MYSQL数据库里面有一个数据库,名字教做mysql,里面有个表,名字叫做user,你看一下这个表的结构和现有数据,你就知道应该怎么做了,比如你可以添加一条数据,Host为你指定的IP,user可以是%,password就不管了,后面设置相应的权限(可以全部都是Y),这样那个机器无论用什么用户和密码都可以连接数据库,而拥有你指定的权限。

耐心点吧,我相信你一看就明白。
参考资料:blog.chinaunix.net/u2/73743/showart_1094545.html
 

www.htsjk.Com true http://www.htsjk.com/shujukunews/3529.html NewsArticle MySQL新增用户以及数据库访问授权,mysql新增 # mysql -u root -p# 允许本地 IP 访问 localhost, 127.0.0.1# insert into mysql.user(Host,User,Password) values(localhost,zhouz,password(1234));# 允许外网 IP 访问# insert i...
评论暂时关闭