Database
FAQ
Can I connect
to my database from a remote server?
Yes. To do
this you will need to setup an SSH tunnel. The SSH tunnel provides
a secure and authenticated means of talking to the database server.
The SSH tunnel
maps a port on your machine to the same port on the database server.
Putty SSH Tunnel
Go to the Connection
-> SSH -> Tunnels menu.
In the section
'Port forwarding'
Set the source port to 3306 for MySQL, or 5432 for PostgreSQL
Set the destination to 127.0.0.1:3306 for MySQL, or 127.0.0.1:5432
for PostgreSQL.
Check the 'Local' option.
Click the 'Add' button.
Then initialize
the SSH connection. Even if you are not using putty, the putty session
needs to remain open to connect to the database.
Command line
SSH Tunnel
Run the command:
ssh username@domainname -L port 127.0.0.1:port
Where:
- username
is the username you use to connect to the server
- domainname
is your website's domain
- port is 3306
for MySQL or 5432 for PostgreSQL
How do I export/dump
tables or databases from PostgreSQL?
The pg_dump
command allows you to dump data from the database.
To dump
an entire database with schema run:
pg_dump -u database_name > dump_file.txt
Then type your username hit return, then type your password and
hit return.
database_name
should be replaced with your username
dump_file.txt is the filename to write the contents of the dump
to.
To dump
a single table with schema run:
pg_dump -u -t table_name database_name > dump_file.txt
Again type your username, hit return and type your password, hit
return
table_name
and database_name should be replaced with table and database names
respectively.
For more detailed
information type pg_dump --help in the shell.
How do I dump/export
entire tables or databases from MySQL?
The mysqldump
command allows you to dump data from the database.
To dump
an entire database with schema run:
mysqldump database_name > dump_file.txt
database_name
should be replaced with your username
dump_file.txt is the filename to write the contents of the dump
to.
For more detailed
information type mysqldump --help in the shell.
Tthe control
panel provides a web based interface to your MySQL database. This
interface includes tools to dump/backup your database.

|