新开了个项目,数据库也想新搞个用户,先登陆mysql,看看原来都有哪些:

root@wlf:/# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.7.-log MySQL Community Server (GPL) Copyright (c) , , Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> select host,user from mysql.user;
+-----------+---------------+
| host | user |
+-----------+---------------+
| % | backup |
| % | hellodevelop |
| % | hellocloud |
| % | passerby |
| % | hellomg |
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
+-----------+---------------+
rows in set (0.00 sec)

  我们新增一个prize用户:

mysql> create user 'prize'@'%' identified by 'prize';
Query OK, rows affected (0.11 sec) mysql> select host,user from mysql.user;
+-----------+---------------+
| host | user |
+-----------+---------------+
| % | backup |
| % | hellodevelop |
| % | hellocloud |
| % | passerby |
| % | prize |
| % | hellomg |
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
+-----------+---------------+
rows in set (0.00 sec)

  

  但这会儿新用户是没有任何操作权限的,除了看看:

mysql> show grants for 'prize'@'%';
+-----------------------------------+
| Grants for prize@% |
+-----------------------------------+
| GRANT USAGE ON *.* TO 'prize'@'%' |
+-----------------------------------+
row in set (0.00 sec)

  

  所以我们还得给它赋予各种权限:

mysql> grant all privileges on `prize`.* to 'prize'@'%';
Query OK, rows affected (0.04 sec) mysql> show grants for 'prize'@'%';
+--------------------------------------------------+
| Grants for prize@% |
+--------------------------------------------------+
| GRANT USAGE ON *.* TO 'prize'@'%' |
| GRANT ALL PRIVILEGES ON `prize`.* TO 'prize'@'%' |
+--------------------------------------------------+
rows in set (0.00 sec)

  刷新一下权限:

mysql> flush privileges;
Query OK, rows affected (0.09 sec)

  现在可以进入prize用户开始我们的倒腾了:

mysql> exit;
Bye
root@d5afa9102517:/# mysql -uprize -pprize
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.7.-log MySQL Community Server (GPL) Copyright (c) , , Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> create database prize;
Query OK, row affected (0.09 sec)

最新文章

  1. JS各种方法
  2. python的os模块
  3. 【android】Android am命令使用
  4. Delphi数组
  5. HDU5831
  6. 解决ADB端口占用问题
  7. PHP 错误与异常 笔记与总结(17 )像处理异常一样处理 PHP 错误
  8. SimpleTagImageView
  9. 01 整合IDEA+Maven+SSM框架的高并发的商品秒杀项目之业务分析与DAO层
  10. C#编程中的Image/Bitmap与base64的转换及 Base-64 字符数组或字符串的长度无效问题 解决
  11. C# 神奇的Web services 请求超时问题 排查分析
  12. 魔力Python——对象
  13. vue学习的笔记补充
  14. electron打包之真的恶心
  15. Effective Java 第三版——82. 线程安全文档化
  16. ABP框架系列之四十:(Notification-System-通知系统)
  17. Entity Framework系列文章目录
  18. SVG.js 文本绘制整理
  19. 教你如何制作饼干icon教程
  20. Linux | GCC如何实现代码编译&&汇编&&链接过程

热门文章

  1. Prometheus(五):Prometheus+Alertmanager 配置企业微信报警
  2. Oracle rman备份还原
  3. httprunner学习7-extract提取content返回对象
  4. Caused by: javax.persistence.TransactionRequiredException: Executing an update/delete query
  5. python基础知识笔记-集合
  6. getLog(this.getClass()) 与 getLog(XXX.class) 的区别
  7. python2和python3共存方法
  8. python基础语法3 整形,浮点,字符串,列表
  9. django-评论
  10. 创建Maven之后,Java包下无法直接创建servlet的原因: