### Setting Up Remote Database Hosting

If you are going to use a Plesk-managed server as a remote database server, you do not need to install MySQL software: Plesk comes with MySQL software, which is automatically installed during installation of Plesk. In this case, you only need to enable network access to this database server and then register it with Plesk.

To set up a MySQL database server:

1. Copy to your server a MySQL distribution package from your operating system distribution disk, or download it from www.mysql.com site and save it on your server.
2. Log in as root to your server and change to the directory where you saved the RPM distribution. Type the following command at the prompt:

   ``rpm -ivh`` `mysql_file_name.rpm`

3. Set the database server administrator's password. Type the following command at the prompt:

   ``mysqladmin -u root password your_desired_password``

   Change your_desired_password to anything you like.

4. Now proceed to the instructions on registering your database server with Plesk.

To set up a PostgreSQL database server:

1. Copy to your server a PostgreSQL distribution package from your operating system distribution disk, or download it from www.postgresql.org site and save it on your server.
2. Log in as root to the server where you want to host databases, and change to the directory where you saved the distribution package.
3. Install the package in a way suitable for your operating system.
   - For RPM based Linux systems, type the following command at the prompt:

     ``rpm -ivh postgresql_file_name.rpm``

   - For deb package based Linux systems, issue the command:

     ``apt-get install package_name``

   - For FreeBSD systems, to install from a package, issue the following command:

     ``pkg_add pgsql-<version>.tgz``

   - To install from ports, issue the following commands:

     ``cd /usr/ports/databases/postgresql<version>-server``

     ``make install package clean``

4. Open the file `/var/lib/pgsql/data/postgresql.conf` with a text editor. If you are installing PostgreSQL version earlier than 8, add the line `tcpip_socket = true` to this file. If you are installing PostgreSQL version later than 8, add the line `listen_addresses = '*'`.
5. Open the file `/var/lib/pgsql/data/pg_hba.conf` with a text editor and make sure the following lines are there:

   ``# local DATABASE USER METHOD [OPTION]``

   ``local samegroup all password``

   ``# host DATABASE USER IP-ADDRESS IP-MASK METHOD [OPTION]``

   ``host samegroup all 0.0.0.0 0.0.0.0 md5``

6. To restart PostgreSQL, issue the following command at the prompt:

   ``service postgresql restart``

7. To set the database server administrator's password, issue the following commands at the prompt (change 'your_desired_password' to anything you like):

   `psql -d template1 -U postgres`

   ``alter user postgres with password 'your_desired_password';``

8. Now proceed to the instructions on registering your database server with Plesk.

To register a database server with Plesk:

1. Log in to Plesk.
2. Click the Server shortcut in the navigation pane.
3. Click the Database Servers icon in the Services group.
4. Click the Add Database Server icon in the Tools group.
5. Specify the properties of the database server:
   - Specify hostname or IP address of the database server.
   - Specify the port number the database server is listening on. By default, MySQL servers listen on port 3306, and PostgreSQL on port 5342. You can leave the Port number box blank, if your database server is listening on the default port.
   - Specify which database type is running on the database server.
   - To make this database server default for hosting customers' databases, select the check box labeled Use this server as default for MySQL. If you have a PostgreSQL database server, select the check box labeled Use this server as default for PostgreSQL.
   - Specify the database server administrator's login name and password.
6. Click OK.

To set up database hosting preferences that will affect all databases created through Plesk:

1. Go to Server > Database Servers > Preferences.
2. To simplify maintenance of customers' databases, select the Force Database Prefix check box. All names of newly created databases will look like client's login name_database name. This will allow you to locate databases related to a particular Plesk user. Note that even if you do not select this check box, on creation of a new database, Plesk will add client's login name to the database name input box, and you will be able to edit it or remove it.
3. Specify whether creation of databases is allowed on your Plesk server. Some applications do not support remote databases and can work only with databases hosted on the same server. We recommend leaving the default option Allow local hosting of databases for these site applications selected, otherwise, you will not be able to use such applications.
4. Click OK.