mysql新增用户
新开了个项目,数据库也想新搞个用户,先登陆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)
mysql新增用户的更多相关文章
- 解决MySQL新增用户无法登陆问题
1. 新增用户 grant all on *.* to '库名'@'%' identified by '库名'; 2. 刷新授权表 flush privileges; 3. 删除空用户 use mys ...
- 5.7.27版本mysql新增用户
因为我们目前只有root,所以只能先用root登陆mysql,再新增用户: $ bin/mysql -u root -p Enter password: Welcome to the MySQL mo ...
- mysql新增用户无法登陆问题解决ERROR 1045 (28000)
mysql增加新用户无法登陆解决方法 ERROR 1045 (28000): Access denied for user 'appadmin'@'localhost' (using password ...
- Mysql新增用户,权限管理
MySQL 赋予用户权限命令的简单格式可概括为:grant 权限 on 数据库对象 to 用户 一.grant 普通数据用户,查询.插入.更新.删除 数据库中所有表数据的权利. grant selec ...
- MySQL新增用户及赋予权限
创建用户 USE mysql; #创建用户需要操作 mysql 表 # 语法格式为 [@'host'] host 为 'localhost' 表示本地登录用户,host 为 IP地址或 IP 地址区间 ...
- MySQL新增用户以及数据库访问授权
# mysql -u root -p # 允许本地 IP 访问 localhost, 127.0.0.1 # insert into mysql.user(Host,User,Password) va ...
- mysql新增用户并开启远程连接
之前使用mysql一直使用root来连接登录数据库,现在想使用新的用户名来连接数据库,碰到数据连接不上的情况. 把这些记录下来,以备后用 1.首先,创建用户 CREATE USER 'xiazhenx ...
- mysql新增用户无法授权!? 解决方案
先上解决方法 :) 创建用户cat 密码 CREATE USER '; 修改user表中的注册用户cat update user set host='%' where user='cat'; 授权: ...
- ubuntu mysql新增用户并开启远程连接
1.首先用root用户登录mysql mysql -u root -p 输入密码后登录成功 2.新建用户 use mysql; select host,user from user;(查看现有用户) ...
随机推荐
- loadrunner中web_submit_data与web_submit_form区别
以loadrunner自带的订票系统为例 当选择红框选中的模式时,所录脚本如下:回放时可以正常回放,登录成功 选另一种所录脚本如下:回放时登录不成功,session失效, 其中web_submit_f ...
- python应用-跑马灯
import os import time def main(): str1='欢迎来到前锋学习Python' while True: os.system('cls') print(str1) tim ...
- 17-Flutter移动电商实战-首页_楼层区域的编写
1.楼层标题组件 该组件非常简单,只接收一个图片地址,然后显示即可: class FloorTitle extends StatelessWidget { final String picture_ ...
- 在没有符号和FPO的情况下遍历堆栈(帧指针省略)
下面是应用程序崩溃转储的调用堆栈.报告的崩溃是名为“HelperLibrary”的模块内的访问冲突,我们没有该模块的符号或源代码.调用堆栈看起来不太可能: 0:000> kv ChildEBP ...
- CF1245F: Daniel and Spring Cleaning
CF1245F: Daniel and Spring Cleaning 题意描述: 给定区间\([L,R]\),其中 \((0\leq L,R\leq 10^9)\),问在区间内有多少数对\((x,y ...
- matlab 只安装部分产品
- 【CF1225E Rock Is Push】推岩石
题目描述 你现在在一个\(n×m\)的迷宫的左上角(即点\((1,1)\)),你的目标是到达迷宫的右下角(即点\((n,m)\)).一次移动你只能向右或者是向下移动一个单位.比如在点\((x,y)\) ...
- gitlab 从古老的 bitnami 版本 迁移到官方最新版本
这是我之前发布在 yuque 的文章.是我刚来新公司的时候帮公司搬迁 git 记录下来的,现在看来去掉敏感部分直接发布也没啥问题啦,就搬家过来,我自己也方便查 XD . 8.1.6 -> 10. ...
- HDU图论题单
=============================以下是最小生成树+并查集====================================== [HDU] 1213 How Many ...
- Web 开发中 文件上传 是出现的:java.io.FileNotFoundException: (文件名、目录名或卷标语法不正确。)
<span style="font-family: Arial, Helvetica, sans-serif; "> </span> <span st ...