mysql新增用户
2024-09-14 00:07:26
新开了个项目,数据库也想新搞个用户,先登陆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)
最新文章
- JS各种方法
- python的os模块
- 【android】Android am命令使用
- Delphi数组
- HDU5831
- 解决ADB端口占用问题
- PHP 错误与异常 笔记与总结(17 )像处理异常一样处理 PHP 错误
- SimpleTagImageView
- 01 整合IDEA+Maven+SSM框架的高并发的商品秒杀项目之业务分析与DAO层
- C#编程中的Image/Bitmap与base64的转换及 Base-64 字符数组或字符串的长度无效问题 解决
- C# 神奇的Web services 请求超时问题 排查分析
- 魔力Python——对象
- vue学习的笔记补充
- electron打包之真的恶心
- Effective Java 第三版——82. 线程安全文档化
- ABP框架系列之四十:(Notification-System-通知系统)
- Entity Framework系列文章目录
- SVG.js 文本绘制整理
- 教你如何制作饼干icon教程
- Linux | GCC如何实现代码编译&;&;汇编&;&;链接过程
热门文章
- Prometheus(五):Prometheus+Alertmanager 配置企业微信报警
- Oracle rman备份还原
- httprunner学习7-extract提取content返回对象
- Caused by: javax.persistence.TransactionRequiredException: Executing an update/delete query
- python基础知识笔记-集合
- getLog(this.getClass()) 与 getLog(XXX.class) 的区别
- python2和python3共存方法
- python基础语法3 整形,浮点,字符串,列表
- django-评论
- 创建Maven之后,Java包下无法直接创建servlet的原因: