在CentOS上设置PostgreSQL用户权限,你需要使用psql
命令行工具或者图形界面工具(如pgAdmin)。以下是使用psql
命令行工具设置用户权限的步骤:
sudo yum install postgresql-server postgresql-contrib
sudo systemctl start postgresql
postgres
用户身份登录到psql
命令行工具:sudo -u postgres psql
CREATE USER your_username WITH PASSWORD 'your_password';
CREATE DATABASE your_database;
GRANT ALL PRIVILEGES ON DATABASE your_database TO your_username;
GRANT SELECT, INSERT, UPDATE, DELETE ON DATABASE your_database TO your_username;
GRANT ALL PRIVILEGES ON SCHEMA your_schema TO your_username;
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA your_schema TO your_username;
GRANT your_role TO your_username;
\q
命令退出psql
命令行工具。注意:请确保将your_username
、your_password
、your_database
和your_schema
替换为你实际使用的用户名、密码、数据库名和模式名。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
相关推荐:CentOS中如何设置PostgreSQL用户权限