在CentOS系统上设置pgAdmin图形界面的步骤如下:
sudo yum install -y gcc make readline -devel zlib-devel
wget https://ftp.postgresql.org/pub/source/v13.4/postgresql-13.4.tar.gz
tar -xzvf postgresql-13.4.tar.gz
cd postgresql-13.4
./configure --prefix=/usr/local/pgsql
make
sudo make install
sudo useradd -m postgres
sudo su - postgres
psql -c "alter user postgres with password 'your_password';"
exit
/usr/local/pgsql/data/postgresql.conf,允许远程连接:sudo vi /usr/local/pgsql/data/postgresql.conf
将以下行修改为:
listen_addresses = '*'
pg_hba.conf 文件以允许远程连接:sudo vi /usr/local/pgsql/data/pg_hba.conf
在文件末尾添加以下行:
host all all 0.0.0.0/0 md5
sudo systemctl enable --now postgresql
sudo yum install -y pgadmin4
pgadmin4.conf 文件:sudo cp /etc/httpd/conf.d/pgadmin4.conf.sample /etc/httpd/conf.d/pgadmin4.conf
sudo vi /etc/httpd/conf.d/pgadmin4.conf
加入以下内容:
VirtualHost *:80
ServerName pgadmin.cn
sudo systemctl restart httpd
在pgAdmin的配置文件 /usr/lib/python3.6/site-packages/pgadmin4-web/config_distro.py 中设置日志文件、SQLite路径、会话数据库路径、存储路径等。
使用Python脚本创建用户:
sudo python3 /usr/lib/python3.6/site-packages/pgadmin4-web/setup.py
按照提示输入邮箱和密码。
更改界面语言为中文:
打开pgAdmin,点击顶部菜单栏的 “File” - “Preferences”。
选择 “Miscellaneous” - “User Language”,设置语言为中文。
设置pgAdmin权限:
在pgAdmin中,可以创建新的角色(role),并为这些角色分配不同的权限。角色可以管理数据库连接、执行SQL查询、创建和修改数据库对象等。
登录pgAdmin。点击左侧导航栏中的“服务器” - “角色”。
点击“”创建新角色,并输入角色名称和密码。
选择角色可以访问的数据库和权限。
点击“保存”保存设置。
请注意,具体的安装步骤和配置可能会因CentOS版本和pgAdmin版本的不同而有所差异。建议参考官方文档或相关社区资源以获取最新的安装指南和配置示例。