How to allow remote access to databases
MySQL
Configure MySQL to listen for remote connections:
sed -i "s/^bind-address/#bind-address/" /etc/mysql/my.cnf
Configure MySQL to accept remote root connections (from any host ('%')):
(added line breaks for readability)
MYSQL_BATCH="mysql --user=root --password=$MYSQL_PASS --batch"
$MYSQL_BATCH --execute "INSERT INTO mysql.user ( Host , User , Password , Select_priv ,
Insert_priv , Update_priv , Delete_priv , Create_priv , Drop_priv , Reload_priv ,
Shutdown_priv , Process_priv , File_priv , Grant_priv , References_priv ,
Index_priv , Alter_priv , Show_db_priv , Super_priv , Create_tmp_table_priv ,
Lock_tables_priv , Execute_priv , Repl_slave_priv , Repl_client_priv ,
Create_view_priv , Show_view_priv , Create_routine_priv , Alter_routine_priv ,
Create_user_priv , ssl_type , max_questions , max_updates , max_connections ,
max_user_connections) VALUES ( '%', 'root', '', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y',
'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y','Y', 'Y', 'Y', 'Y', 'Y',
'Y', 'Y', 'Y', 'Y', '', '0', '0', '0', '0');"
Restart MySQL for the changes to take effect:
/etc/init.d/mysql restart
PostgreSQL
Configure PostgreSQL to listen for remote connections:
CONF=/etc/postgresql/8.3/main/postgresql.conf sed -i "s/#listen_addresses = 'localhost'/listen_addresses = '*'/" $CONF
Configure PostgreSQL to accept remote connections (from any host):
# configure postgres to accept remote connections cat >> /etc/postgresql/8.3/main/pg_hba.conf <<EOF # Accept all IPv4 connections - CHANGE THIS!!! host all all 0.0.0.0/0 md5 EOF
Restart PostgreSQL for the changes to take effect:
/etc/init.d/postgresql-8.3 restart
