如何在 yugabyte db 中创建带密码的用户、删除角色和拥有所有权的数据库?
How to create user with password, drop roles and database with ownership in yugabyte db?
Objective: 创建带密码的用户,在 yugabyte
中删除拥有所有权的角色和数据库
执行的命令:
cd /opt/yugabyte/yugabyte-1.3.0.0/bin
psql -h localhost -p 5433 -U postgres -d postgres -W
\i /index/yugabyte/yugastore.sql
日志:
postgres=# \i /index/yugabyte/yugastore.sql
Password for user postgres:
psql (9.2.24, server 11.2)
WARNING: psql version 9.2, server version 11.0.
Some psql features might not work.
You are now connected to database "postgres" as user "postgres".
psql:/index/yugabyte/yugastore.sql:9: ERROR: database "yugastore" does not exist
psql:/index/yugabyte/yugastore.sql:11: ERROR: DROP USER not supported yet
LINE 1: DROP USER ydba;
^
HINT: See https://github.com/YugaByte/yugabyte-db/issues/869. Click '+' on the description to raise its priority
psql:/index/yugabyte/yugastore.sql:13: ERROR: CREATE USER ROLE with element not supported yet
LINE 1: CREATE USER ydba WITH PASSWORD 'ydba123';
^
HINT: See https://github.com/YugaByte/yugabyte-db/issues/869. Click '+' on the description to raise its priority
psql:/index/yugabyte/yugastore.sql:15: ERROR: role "ydba" does not exist
请帮我解决问题![=12=]
Download 数据库:
wget https://downloads.yugabyte.com/yugabyte-2.0.10.0-linux.tar.gz
tar xvfz yugabyte-2.0.10.0-linux.tar.gz && cd yugabyte-2.0.10.0/
./bin/post_install.sh
./bin/yb-ctl create
./bin/ysqlsh
Sql代码:
yugabyte=# create database ydb;
CREATE DATABASE
yugabyte=# create user ydba WITH PASSWORD 'ydba123';
CREATE ROLE
yugabyte=# ALTER DATABASE ydb OWNER TO ydba;
ALTER DATABASE
yugabyte=# drop user ydba;
ERROR: role "ydba" cannot be dropped because some objects depend on it
DETAIL: owner of database ydb
yugabyte=# drop database ydb;
DROP DATABASE
yugabyte=# drop user ydba;
DROP ROLE
yugabyte=#
Objective: 创建带密码的用户,在 yugabyte
中删除拥有所有权的角色和数据库执行的命令:
cd /opt/yugabyte/yugabyte-1.3.0.0/bin
psql -h localhost -p 5433 -U postgres -d postgres -W
\i /index/yugabyte/yugastore.sql
日志:
postgres=# \i /index/yugabyte/yugastore.sql
Password for user postgres:
psql (9.2.24, server 11.2)
WARNING: psql version 9.2, server version 11.0.
Some psql features might not work.
You are now connected to database "postgres" as user "postgres".
psql:/index/yugabyte/yugastore.sql:9: ERROR: database "yugastore" does not exist
psql:/index/yugabyte/yugastore.sql:11: ERROR: DROP USER not supported yet
LINE 1: DROP USER ydba;
^
HINT: See https://github.com/YugaByte/yugabyte-db/issues/869. Click '+' on the description to raise its priority
psql:/index/yugabyte/yugastore.sql:13: ERROR: CREATE USER ROLE with element not supported yet
LINE 1: CREATE USER ydba WITH PASSWORD 'ydba123';
^
HINT: See https://github.com/YugaByte/yugabyte-db/issues/869. Click '+' on the description to raise its priority
psql:/index/yugabyte/yugastore.sql:15: ERROR: role "ydba" does not exist
请帮我解决问题![=12=]
Download 数据库:
wget https://downloads.yugabyte.com/yugabyte-2.0.10.0-linux.tar.gz
tar xvfz yugabyte-2.0.10.0-linux.tar.gz && cd yugabyte-2.0.10.0/
./bin/post_install.sh
./bin/yb-ctl create
./bin/ysqlsh
Sql代码:
yugabyte=# create database ydb;
CREATE DATABASE
yugabyte=# create user ydba WITH PASSWORD 'ydba123';
CREATE ROLE
yugabyte=# ALTER DATABASE ydb OWNER TO ydba;
ALTER DATABASE
yugabyte=# drop user ydba;
ERROR: role "ydba" cannot be dropped because some objects depend on it
DETAIL: owner of database ydb
yugabyte=# drop database ydb;
DROP DATABASE
yugabyte=# drop user ydba;
DROP ROLE
yugabyte=#