mysql重建某个用户账号(ERROR 1396 (HY000): Operation CREATE USER failed)

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介:

说明:在MariaDB中删除了用户molewan后,业务又有需求重新建立一个名为molewan的用户

1、查看数据库,发现已经没有molewan用户了

1
2
3
4
5
6
7
8
MariaDB [mysql]>  select  user,host from mysql.user;
+----------+------------+
| user     | host       |
+----------+------------+
| molewan1 | 10.10.10.% |
| admin    | localhost  |
+----------+------------+
2 rows  in  set  (0.00 sec)

2、新建一个molewan的用户,报错

1
2
3
4
5
MariaDB [mysql]> create user molewan@ '10.10.10.%'  identified by  'molewan' ;
ERROR 1396 (HY000): Operation CREATE USER failed  for  'molewan' @ '10.10.10.%'
想起来删除molewan用户的时候,是通过delete命令删除的
MariaDB [mysql]> delete from mysql.user where user= "molewan1"  and host = "10.10.10.%" ;
MariaDB [mysql]> flush privileges;

3、查了下资料,发现如果要彻底不适用某个用户,推荐使用drop命令进行

1
2
3
4
MariaDB [mysql]> drop user molewan@ '10.10.10.%' ;
Query OK, 0 rows affected (0.00 sec)
MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

补充说明:DROP USER不会自动中止已连接的用户会话,也就是说被删的用户如果在删前已经连接上了服务器,并且连接尚未中断,那它此时还能继续执行一定的操作,只是它的身份已经变成了黑户。

4、重建molewan的用户

1
2
3
4
5
6
7
8
9
10
MariaDB [mysql]> create user molewan@ '10.10.10.%'  identified by  'molewan' ;
Query OK, 0 rows affected (0.01 sec)
MariaDB [mysql]>  select  user,host from mysql.user;
+---------+------------+
| user    | host       |
+---------+------------+
| molewan | 10.10.10.% |
| admin   | localhost  |
+---------+------------+
2 rows  in  set  (0.00 sec)










本文转自 冰冻vs西瓜 51CTO博客,原文链接:http://blog.51cto.com/molewan/1940610,如需转载请自行联系原作者
相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
4月前
|
关系型数据库 MySQL
MySQL 报错 [ERROR] [FATAL] InnoDB: Table flags are 0 in the data dictionary but the flags in file
MySQL 报错 [ERROR] [FATAL] InnoDB: Table flags are 0 in the data dictionary but the flags in file
305 0
|
3月前
|
关系型数据库 MySQL
ERROR 1449 (HY000): The user specified as a definer (‘mysql.infoschema‘@‘localhost‘) does not exist
ERROR 1449 (HY000): The user specified as a definer (‘mysql.infoschema‘@‘localhost‘) does not exist
21 0
|
3月前
|
SQL 数据采集 关系型数据库
如何解决MySQL报错 You have an error in your SQL syntax; check the manual that corresponds to your MySQL?
如何解决MySQL报错 You have an error in your SQL syntax; check the manual that corresponds to your MySQL?
|
16天前
|
关系型数据库 MySQL 数据安全/隐私保护
MySQL连接ERROR 2059 (HY000): Authentication plugin ‘caching_sha2_password‘ cannot be loaded
MySQL连接ERROR 2059 (HY000): Authentication plugin ‘caching_sha2_password‘ cannot be loaded
23 0
|
1月前
|
缓存 关系型数据库 MySQL
MySQL登录时出现Access denied for user ‘root‘@‘localhost‘ (using password: YES)无法打开的解决方法
MySQL登录时出现Access denied for user ‘root‘@‘localhost‘ (using password: YES)无法打开的解决方法
|
6月前
|
关系型数据库 MySQL
Mysql报错:InnoDB: Operating system error number 13 in a fil..的解决方法
Mysql报错:InnoDB: Operating system error number 13 in a fil..的解决方法
107 0
|
2月前
|
关系型数据库 MySQL 数据库
连接mysql报Access denied for user 'root'@'localhost'错误的解决办法
连接mysql报Access denied for user 'root'@'localhost'错误的解决办法
|
4月前
|
Ubuntu 关系型数据库 MySQL
Mysql Access denied for user ‘root‘@ ‘*.*.*.*‘ (using password: YES)异常处理
Mysql Access denied for user ‘root‘@ ‘*.*.*.*‘ (using password: YES)异常处理
49 0
Mysql Access denied for user ‘root‘@ ‘*.*.*.*‘ (using password: YES)异常处理
|
5月前
|
关系型数据库 MySQL
mysql: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such
mysql: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such
|
5月前
|
SQL 关系型数据库 MySQL
Could not execute query ---> MySql.Data.MySqlClient.MySqlException: You have an error in your SQL sy
Could not execute query ---> MySql.Data.MySqlClient.MySqlException: You have an error in your SQL sy
20 0

推荐镜像

更多