Can we create a database on remote machine in postgresql DB, if yes then how?
-
If you have the needed permissions AND the postgres server itself is installed/running on that machine then yes... please elaborate with details...what have you tried ? what is not working ?Yahia– Yahia2011-11-16 07:26:53 +00:00Commented Nov 16, 2011 at 7:26
-
I am writing a script that i will run fom my local machine.Amit Singh Tomar– Amit Singh Tomar2011-11-16 07:30:43 +00:00Commented Nov 16, 2011 at 7:30
-
that doesn't say much... what kind of script ? what is installed/running on the remote machine ?...Yahia– Yahia2011-11-16 07:32:24 +00:00Commented Nov 16, 2011 at 7:32
-
I am writing a script that i will run fom my local machine. This script copy the db from local machine and upload in the remote machine but i want to create the db from my local machine to remote machine.Amit Singh Tomar– Amit Singh Tomar2011-11-16 07:33:08 +00:00Commented Nov 16, 2011 at 7:33
-
that didn't answer my questions... sorry this way I don't see how I could help...Yahia– Yahia2011-11-16 07:34:58 +00:00Commented Nov 16, 2011 at 7:34
2 Answers
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
2 Comments
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.