Posts

Making an external connection to a Blaknight MySQL database

You can connect to a Blacknight MySQL database from an external tool (e.g. mysql or mysqlimport commandline) if you change some of the database’s settings. This can be useful if you need to manage your database, for example if you need to perform a large database import (one that is so large it causes phpMyAdmin to time out).

First you need to configure the database to allow external connections, in the Blacknight control panel choose to edit the database’s settings and check the ‘Access from external hosts’ check-box. This change on its own isn’t sufficient, next you must add your ip address to the ‘Access Hosts’ list.

enable_external_access

When on the database properties page, click on the ‘Access Hosts’ tab, click on ‘Add new access host’ and add your ip address. To find your IP address, just google ‘my ip address’ and your address will be displayed near the top of the results page.

add_ip_address_blacknight

Once you have made these changes you should be able to make external connections to the database. When you are finished it is probably a good idea to remove external access again.

You can now do something like import a database, get the hostname from the ‘external hostname’ field on the blacknight control panel:

mysql --host="mysq12666.cp.blacknight.com"   --user='u1273449_the_user' --password="ThePassword" database_name < ./db4.sql

Drupal 7 – Backslashes being added to quotes on Blacknight Hosting

This is a very strange and annoying problem, when editing content on a Drupal 7 installation backslashes were being automatically put before quotes – a real pain especially when editing HTML!

 

This is a well known issue caused by a silly PHP5 module called ‘magic quotes’. Anyway on Blacknight I found that the only way to get rid of the problem was to make sure that magic quotes functionality was turned on in .htaccess – this would force Drupal to successfully work around the issue. The way to do this is to make sure the the following is included the .htaccess file:

 
  php_flag magic_quotes_gpc          on
  php_flag magic_quotes_sybase       on
...

This seems counter intuitive – surely we want to turn magic quotes off? however, including these lines in the file lets Drupal 7 know that the magic quotes functionality is turned on and then it successfully fixes the problem itself..