命令行下创建MySQL数据库与创建用户以及授权
先以root用户登录mysql: C:UsersXXX>mysql -u root -p 输入密码后登录,接下来操作如下: 1、创建数据库 语法:create schema [数据库名称] default character set utf8 collate utf8_general_ci; 采用create schema和create database创建数据库的效果一样。 示例:create schema spring_boot_demo default character set utf8 collate utf8_general_ci; 2、创建用户 语法:create user '[用户名称]'@'%' identified by '[用户密码]'; 密码8位以上,包括:大写字母、小写字母、数字、特殊字符 %:匹配所有主机,该地方还可以设置成‘localhost’,代表只能本地访问,例如root账户默认为‘localhost‘ 示例:create user 'szh'@'localhost' identified by '123456'; 3、用户授权数据库 grant select,insert,update,delete,create on [数据库名称].* to [用户名称]@'%'; *代表整个数据库 示例:grant select,create on spring_boot_demo.* to szh@'localhost'; 4、立即启用修改 flush ?privileges ; ? 5、取消用户szh所有数据库(表)的所有权限 revoke all on *.* from szh; 6、删除用户szh delete from mysql.user where user='szh'; 7、删除数据库 drop database [schema名称|数据库名称]; ? PS : 在操作过程中如果遇到错误 "The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement" 则先进行一下刷新操作: mysql> flush privileges; --这样就可以接着操作了
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- 在64位系统上部署BDE的要点
- windows-server-2008 – 导出/打印所有角色和功能
- 如何在Windows Server PPTP VPN中自动为客户端分配路由?
- Windows 7上的内联函数的doParallel问题(适用于Linux)
- get-event-store – Windows Azure上的事件存储无法从外部访
- windows-7 – Windows 7上的Windows批处理文件问题
- 电子邮件 – Office 365 Hosted Exchange发生奇怪的未送达行
- iis-7 – 可以在XP上安装IIS7吗?
- “Microsoft”有一个用于解决Exchange问??题的在线工具 –
- Windows API一日一练 21 SetWindowLongPtr和GetWindowLongP