mysql cluster 用户_mysql cluster统一用户权限
统一用户权限
使用mysql cluster由于存放用户信息的表user是指mysql库里面的,而且这些表是MyISAM存储引擎的。如果希望所有的sql节点都有统一的用户权限,可以把创建用户的脚本在每个sql节点都执行一下,这样比较麻烦。可以使用mysql cluster的一个新特性来完成这些操作。就是把mysql cluster的sql节点的用户权限表转换成NDB数据库引擎的表。
下面是在其中一个sql节点的操作
[root@vmhost02 local]# mysql -u root -ppassword
Welcome to the MySQL monitor.Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.5.27-ndb-7.2.8-cluster-gpl MySQL Cluster Community Server (GPL)
Copyright (c) 2000, 2011, 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> show databases;
+--------------------+
| Database|
+--------------------+
| information_schema |
| cacti|
| data|
| db_nagiosql_v32|
| egroupware|
| events|
| fanwe|
| jiqun|
| joffice131|
| jofficev1_2|
| mysql|
| phpgroupware|
| test|
| ultrax|
| vmdb|
+--------------------+
15 rows in set (0.00 sec)
mysql> grant all on jiqun.* to 'user1'@'%' identified by 'password';
Query OK, 0 rows affected (0.00 sec)
mysql> use jiqun
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+-----------------+
| Tables_in_jiqun |
+-----------------+
| tb1|
| tb2|
+-----------------+
[root@vmhost02 ~]# mysql -u user1 -ppassword -h 192.168.163.110
Welcome to the MySQL monitor.Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.5.27-ndb-7.2.8-cluster-gpl MySQL Cluster Community Server (GPL)
Copyright (c) 2000, 2011, 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 * from jiqun.tb1;
+-------+
| colid |
+-------+
|3 |
|2 |
|1 |
+-------+
3 rows in set (0.00 sec)
mysql>
这些是最另外一个节点操作的
[root@vmhost06 ~]# mysql -u user1 -ppassword
ERROR 1045 (28000): Access denied for user 'user1'@'localhost' (using password: YES)
[root@vmhost06 ~]# mysql -u user1 -ppassword -h 192.168.163.160
ERROR 1045 (28000): Access denied for user 'user1'@'192.168.163.160' (using password: YES)
下面是转换用户权限表的操作,就两步,简单吧!
[root@vmhost02 ~]# mysql -u root -ppassword
Welcome to the MySQL monitor.Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.5.27-ndb-7.2.8-cluster-gpl MySQL Cluster Community Server (GPL)
Copyright (c) 2000, 2011, 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> source /usr/share/mysql/ndb_dist_priv.sql
Query OK, 0 rows affected, 1 warning (0.04 sec)
Query OK, 0 rows affected, 1 warning (0.00 sec)
Query OK, 0 rows affected, 1 warning (0.00 sec)
Query OK, 0 rows affected, 1 warning (0.00 sec)
Query OK, 0 rows affected, 1 warning (0.00 sec)
Query OK, 0 rows affected, 1 warning (0.00 sec)
Query OK, 0 rows affected, 1 warning (0.00 sec)
Query OK, 0 rows affected (0.02 sec)
Query OK, 0 rows affected (0.01 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
mysql> call mysql.mysql_cluster_move_privileges();
Query OK, 1 row affected (5.08 sec)
mysql> show create table mysql.user\G;
*************************** 1. row ***************************
Table: user
Create Table: CREATE TABLE `user` (
`Host` char(60) COLLATE utf8_bin NOT NULL DEFAULT '',
`User` char(16) COLLATE utf8_bin NOT NULL DEFAULT '',
`Password` char(41) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
`Select_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Insert_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Update_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Delete_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Create_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Drop_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Reload_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Shutdown_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Process_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`File_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Grant_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`References_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Index_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Alter_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Show_db_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Super_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Create_tmp_table_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Lock_tables_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Execute_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Repl_slave_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Repl_client_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Create_view_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Show_view_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Create_routine_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Alter_routine_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Create_user_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Event_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Trigger_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`Create_tablespace_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
`ssl_type` enum('','ANY','X509','SPECIFIED') CHARACTER SET utf8 NOT NULL DEFAULT '',
`ssl_cipher` blob NOT NULL,
`x509_issuer` blob NOT NULL,
`x509_subject` blob NOT NULL,
`max_questions` int(11) unsigned NOT NULL DEFAULT '0',
`max_updates` int(11) unsigned NOT NULL DEFAULT '0',
`max_connections` int(11) unsigned NOT NULL DEFAULT '0',
`max_user_connections` int(11) unsigned NOT NULL DEFAULT '0',
`plugin` char(64) COLLATE utf8_bin DEFAULT '',
`authentication_string` text COLLATE utf8_bin,
PRIMARY KEY (`Host`,`User`)
) ENGINE=ndbcluster DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Users and global privileges'
1 row in set (0.01 sec)
ERROR:
No query specified
mysql>
至此,用户在两个sql几点都出现了。而且以后新添加到用户无论是在哪个节点执行的命令,用户都可以在其他节点登录。
mysql cluster 用户_mysql cluster统一用户权限相关推荐
- mysql 存储过程改用户_Mysql修改存储过程相关权限问题
在使用mysql数据库经常都会遇到这么一个问题,其它用户定义的存储过程,现在使用另一个用户却无法修改或者删除等:正常情况下存储过程的定义者对它有修改.删除的权限:但是其它的用户就要相于的授权,不然无法 ...
- mysql授权无密码用户_MySQL下新建用户,授权,删除用户,修改密码
一.创建一个新的用户. 创建用户的方式有两种: 1.create user:就是向用户管理表里插入一个新的用户. 2.最好的方法是使用GRANT语句,因为这样更精确,错误少.从MySQL 3.22.1 ...
- mysql怎么新增_mysql怎么新增用户
匿名用户 1级 2018-01-27 回答 展开全部 首先以root身份登录到MySQL服务器中. $ mysql -u root -p 当验证提示出现的时候,输入MySQL的root帐号的密码. 创 ...
- mysql 建立超级用户_mysql创建超级用户
先 use mysql;然后 mysql>describe user; 显示表 mysql 数据库中 user 表的列信息); 3.grant 创建一个可以从任何地方连接服务器的一个完全的超级用 ...
- mysql 删除root用户_mysql误删root用户解决办法
MySQL删除root用户后恢复 MySQL数据库中有一个超级特权用户,那就是root.root用户有至高无上的权限,它可以创建数据库,创建用户,赋予用户权限,对所以数据库拥有所有的操作权限.一旦这个 ...
- mysql 查所有的用户_MySQL查看所有用户 - MySQL 系列教程
在使用 MySQL 或其它关系型数据库的时候,免不了需要查看所有用户的信息,比如这些用户分别有什么权限,何时创建的之类.这篇文章里我们讨论,如何在 MySQL 中查看所有用户的信息. SHOW DAT ...
- mysql localhost值_mysql数据库中用户表host字段localhost、127.0.0.1、%区别
忘记mysql密码后,通过添加my.cnf中[mysqld]段skip_grant_tables参数跳过认证后修改密码. 改完后重启发现还是无法登陆,排查后发现是mysql.user表中host字段值 ...
- mysql 创建函数_MySQL文件及目录权限设置分析-爱可生
1 背景 创建文件及目录时,我们会对相关的权限有一定的要求,默认的可以通过系统的umask来控制.然而,在我们使用MySQL时,无论是开始使用前的初始化,还是MySQL实例启动后,创建的相关文件及目录 ...
- mysql8.0查看用户_MySQL 8.0用户和角色管理
MySQL8.0新加了很多功能,其中在用户管理中增加了角色的管理, 默认的密码加密方式也做了调整,由之前的sha1改为了sha2,同时加上5.7的禁用用户和用户过期的设置, 这样方面用户的管理和权限的 ...
最新文章
- 读书:历史 -- 奥斯曼帝国六百年
- select sum也会返回null值
- SDN — 技术的发展
- python3菜鸟教程中文-我的python学习方法和资源整理,干货分享
- 阿里P8高级架构师:面试没你想象中的难,拿Offer也可以很轻松
- MySQL当您插入列无效的数据插入
- 父框架与子框架的互操作
- mr利用mapjoin计算出每个部门的总工资以及部门名称
- 【贯穿】.NET6结合Docker傻瓜式实现容器编排
- python web开发实录
- 奔图 Pantum P3502DN 打印机驱动
- 以编程方式打印 XPS 文件
- python键盘记录工具开发_多功能Python键盘记录工具:Radium
- 【vs】 试图加载格式不正确的程序
- poi 操作Excel 删除行内容和直接删除行(poi3.17测试可用)
- 【python初学者日记】输入正整数n,求1+2+3+……+n的值
- 命令行配置电脑IP(Windows下设置、增加、删除)
- Access和VBA
- Xenomai——实现一个GNU/Linux上的RTOS的仿真框架
- 如何对ChatGPT进行Prompt逆向工程, Prompt engineering生成Prompt的核心是给出例子,反推生成例子的通用Prompt模板mjourney,给出图片生成该图的Prompt