搜索
首页数据库mysql教程MYSQL添加新用户MYSQL为用户创建数据库MYSQL为新用户分配权限_MySQL

bitsCN.com

MYSQL添加新用户MYSQL为用户创建数据库MYSQL为新用户分配权限

 

1.新建用户

 

//登录MYSQL

@>mysql -u root -p

@>密码

//创建用户

mysql> insert into mysql.user(Host,User,Password) values(‘localhost’,'jeecn’,password(‘jeecn’));

//刷新系统权限表

mysql>flush privileges;

这样就创建了一个名为:jeecn  密码为:jeecn  的用户。

 

//退出后登录一下

mysql>exit;

@>mysql -u jeecn -p

@>输入密码

mysql>登录成功

 

2.为用户授权

 

//登录MYSQL(有ROOT权限)。我里我以ROOT身份登录.

@>mysql -u root -p

@>密码

//首先为用户创建一个数据库(jeecnDB)

mysql>create database jeecnDB;

//授权jeecn用户拥有jeecn数据库的所有权限

@>grant all privileges on jeecnDB.* to jeecn@localhost identified by ‘jeecn’;

//刷新系统权限表

mysql>flush privileges;

mysql>其它操作

 

//如果想指定部分权限给一用户,可以这样来写:

mysql>grant select,update on jeecnDB.* to jeecn@localhost identified by ‘jeecn’;

//刷新系统权限表。

mysql>flush privileges;

 

mysql> grant 权限1,权限2,…权限n on 数据库名称.表名称 to 用户名@用户地址 identified by ‘连接口令’;

 

权限1,权限2,…权限n代表select,insert,update,delete,create,drop,index,alter,grant,references,reload,shutdown,process,file等14个权限。

当权限1,权限2,…权限n被all privileges或者all代替,表示赋予用户全部权限。

当数据库名称.表名称被*.*代替,表示赋予用户操作服务器上所有数据库所有表的权限。

用户地址可以是localhost,也可以是ip地址、机器名字、域名。也可以用’%’表示从任何地址连接。

‘连接口令’不能为空,否则创建失败。

 

例如:

mysql>grant select,insert,update,delete,create,drop on vtdc.employee to jee@10.163.225.87 identified by ‘123′;

给来自10.163.225.87的用户jee分配可对数据库vtdc的employee表进行select,insert,update,delete,create,drop等操作的权限,并设定口令为123。

 

mysql>grant all privileges on vtdc.* to jee@10.10.10.87 identified by ‘123′;

给来自10.163.225.87的用户jee分配可对数据库vtdc所有表进行所有操作的权限,并设定口令为123。

 

mysql>grant all privileges on *.* to jee@10.10.10.87 identified by ‘123′;

给来自10.163.225.87的用户jee分配可对所有数据库的所有表进行所有操作的权限,并设定口令为123。

 

mysql>grant all privileges on *.* to jee@localhost identified by ‘123′;

给本机用户jee分配可对所有数据库的所有表进行所有操作的权限,并设定口令为123。

 

3.删除用户

 

@>mysql -u root -p

@>密码

mysql>DELETE FROM user WHERE User=”jeecn” and Host=”localhost”;

mysql>flush privileges;

//删除用户的数据库

mysql>drop database jeecnDB;

 

4.修改指定用户密码

 

@>mysql -u root -p

@>密码

mysql>update mysql.user set password=password(‘新密码’) where User=”jeecn” and Host=”localhost”;

mysql>flush privileges;

mysql>quit;

bitsCN.com
声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
MySQL:字符串数据类型可用哪些字符集?MySQL:字符串数据类型可用哪些字符集?May 10, 2025 am 12:07 AM

mysqloffersvariouscharactersetsforstringdatatypes:1)latin1 forwesterneuropeanlanguages,2)utf8 formultingualsupport,3)utf8mb4f OREXTEDENDENDENENICODECLUDINGEMOJIS,4)UCS2FORIXED-WIDTHENCODING,5)assiiforbasiclatin.ChoosideStherightStetSetensensersdaintegrity

mysql:斑点流比存储它们更好吗?mysql:斑点流比存储它们更好吗?May 10, 2025 am 12:06 AM

流式传输BLOB确实比直接存储更好,因为它能减少内存使用和提高性能。1)通过逐步读取和处理文件,避免了数据库膨胀和性能下降。2)流式传输需要更复杂的代码逻辑,且可能增加I/O操作次数。

MySQL字符串类型:存储,性能和最佳实践MySQL字符串类型:存储,性能和最佳实践May 10, 2025 am 12:02 AM

mySqlStringTypesimpactStorageAndPerformanCeaseAsfollows:1)长度,始终使用theSamestoragespace,whatcanbefasterbutlessspace-felfficity.2)varCharisvariable varcharisvariable length,morespace-morespace-morespace-effficitybuteftife buteftife butfority butfority textifforlyslower.3)

了解MySQL字符串类型:VARCHAR,文本,char等了解MySQL字符串类型:VARCHAR,文本,char等May 10, 2025 am 12:02 AM

mySqlStringTypesIncludeVarChar,文本,char,enum和set.1)varCharisVersAtileForvariable-lengthStringStringSuptOptoPeptoPepecifientlimit.2)textisidealforlargetStortStorStoverStorextorewiteWithoutAdefinedLengthl.3)charlisfixed-Length

MySQL中的字符串数据类型是什么?MySQL中的字符串数据类型是什么?May 10, 2025 am 12:01 AM

MySQLoffersvariousstringdatatypes:1)CHARforfixed-lengthstrings,2)VARCHARforvariable-lengthtext,3)BINARYandVARBINARYforbinarydata,4)BLOBandTEXTforlargedata,and5)ENUMandSETforcontrolledinput.Eachtypehasspecificusesandperformancecharacteristics,sochoose

如何向新的MySQL用户授予权限如何向新的MySQL用户授予权限May 09, 2025 am 12:16 AM

TograntpermissionstonewMySQLusers,followthesesteps:1)AccessMySQLasauserwithsufficientprivileges,2)CreateanewuserwiththeCREATEUSERcommand,3)UsetheGRANTcommandtospecifypermissionslikeSELECT,INSERT,UPDATE,orALLPRIVILEGESonspecificdatabasesortables,and4)

如何在MySQL中添加用户:逐步指南如何在MySQL中添加用户:逐步指南May 09, 2025 am 12:14 AM

toadduserInmysqleffectection andsecrely,theTheSepsps:1)USEtheCreateuserStattoDaneWuser,指定thehostandastrongpassword.2)GrantNectalRevileSaryPrivilegesSustate,usiveleanttatement,AdheringTotheTeprinciplelastPrevilegege.3)

mysql:添加具有复杂权限的新用户mysql:添加具有复杂权限的新用户May 09, 2025 am 12:09 AM

toaddanewuserwithcomplexpermissionsinmysql,loldtheSesteps:1)创建eTheEserWithCreateuser'newuser'newuser'@''localhost'Indedify'pa ssword';。2)GrantreadAccesstoalltablesin'mydatabase'withGrantSelectOnMyDatabase.to'newuser'@'localhost';。3)GrantWriteAccessto'

See all articles

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

Video Face Swap

Video Face Swap

使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

适用于 Eclipse 的 SAP NetWeaver 服务器适配器

适用于 Eclipse 的 SAP NetWeaver 服务器适配器

将Eclipse与SAP NetWeaver应用服务器集成。

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

EditPlus 中文破解版

EditPlus 中文破解版

体积小,语法高亮,不支持代码提示功能

MinGW - 适用于 Windows 的极简 GNU

MinGW - 适用于 Windows 的极简 GNU

这个项目正在迁移到osdn.net/projects/mingw的过程中,你可以继续在那里关注我们。MinGW:GNU编译器集合(GCC)的本地Windows移植版本,可自由分发的导入库和用于构建本地Windows应用程序的头文件;包括对MSVC运行时的扩展,以支持C99功能。MinGW的所有软件都可以在64位Windows平台上运行。

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

功能强大的PHP集成开发环境