简体   繁体   中英

PostgreSQL Database Creation on Remote machine

我们可以在 postgresql DB 中的远程机器上创建一个数据库,如果是,那么如何?

Yes. Assuming the remote server is Linux, and assuming you have sudo or root privileges on that server, you could SSH into the remote server and use a package manager (like yum, synaptic, or apt) to install the PostgreSQL server.

You can configure it using vi (or emacs or other text editor). Usually, the files you edit are found in the /var/lib/pgsql/data folder, and an /etc/init.d/postgresql startup script for whenever the server reboots. You'll usually need to edit the pg_hba.conf file to allow a connection from your client's subnet. That part can be troublesome if overlooked.

You'll be able to initially run psql as the postgres user, and can create datatabases, run scripts, etc from the command line. Once you allow a remote connection, you can do the same from the comfort of your own gui, such as PgAdminIII or any Java-based database manager that can use a JDBC connector.

Example:

psql -U postgres
create database foo;
\q

First, get your programming language. Let say it's PHP to make it simple.

Second, you get the PostGresql connector . Here is the link for PHP but you can get for all popular language.

Third, you open a connection and you do the command you want. You want to create a database so you call the create database YourDatabaseName command.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM