Here is a guide on how to alter your database connection strings. This is most commonly done after migrating sites. You can edit the majority of the files listed by using your preferred FTP client within the control panel.
Each edit of the database connection strings will require the following information:
Database Name: This should be the name of the database you have created.
Database Username: You should use the username used for the user to access the database here.
Database Password: You should use the password used for the user to access the database here.
Database Prefix: The database prefix is similar to a nickname you give the database so you can quickly identify it when required. You will have set this upon creation of it. (Note: Some database connection strings do not require this)
Database Host: Depending on which version of SQL you are using, you should be using a variation of either mysql.pipeten.co.uk (Sheffield) and dmysql.pipeten.co.uk (Derby), or mssql.pipeten.co.uk (Sheffield) and dmssql.pipeten.co.uk (Derby). The variation can be a number after the prefix mysql or mssql. These prefixes will also help you work out which version of SQL you are using. The guides below will help you find out your database host if you are unsure.
These are a few helpful guides relating to Linux and Windows databases and how to use them on each platform:
Linux:
You can find the guide for finding your database server/host here.
If you’re wanting to create a new MySQL database, there is a guide on how to do so here.
If you’re also wanting to add new users to your MySQL database, you can follow this guide here.
Windows:
You can find the guide for finding your database server/host here.
If you’re wanting to create a new MS SQL database, there is a guide on how to do so here.
If you’re also wanting to add new users to your MS SQL database, you can follow this guide here.
WordPress
The database connection strings for WordPress can be found in the wp-config.php file.
Here is an example of a wp-config.php file.
// ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define('DB_NAME', 'your_database_name'); /** MySQL database username */ define('DB_USER', 'your_database_username'); /** MySQL database password */ define('DB_PASSWORD', 'your_database password'); /** MySQL hostname */ define('DB_HOST', 'your_database_host'); /** Database Charset to use in creating database tables. */ define('DB_CHARSET', 'utf8'); /** The Database Collate type. Don't change this if in doubt. */ define('DB_COLLATE', '');
Your details related to the above need to be put in the corresponding fields within the file.
Once you have done this, make sure you save the new database strings within the file and now WordPress should be able to connect to the specified database as long as you have put in the correct details.
Drupal
Drupal uses the settings.php file to store the database connection strings. Upon installation it would be located here: sites/default/settings.php.
Upon going to edit the settings.php file, you will be greeted with quite a long document. You must find the code within the document that looks similar to this:
$databases['default']['default'] = array ( 'database' => 'your_database_name', 'username' => 'your_database_username', 'password' => 'your_database_password', 'prefix' => 'your_database_prefix', 'host' => 'your_database_host', 'port' => '3306', 'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql', 'driver' => 'mysql', );
This is where you can edit the database connection strings required to establish a connection to the database the site is using.
Each field corresponds with the information you should already have, so inputting your correct database connection strings should be quite straight forward.
Upon inputting the information about your database, you can then save the file and upload it. Your site should now be able to successfully connect to the specified database.
Joomla
Joomla uses the configuration.php file to store the database connection strings. This file can be found in the root directory of the domain you have installed it on, unless you have relocated it.
In order to edit the database connection strings for Joomla, simply open the configuration.php file using your favoured FTP connection method. Once you have done so, you need to find the section in the file that contains the following:
public $dbtype = 'mysqli'; public $host = 'your_database_host'; public $user = 'your_database_username'; public $password = 'your_database_password'; public $db = 'your_database_name'; public $dbprefix = 'your_database_prefix'; public $live_site = '';
Here, you can edit the contents so that Joomla can connect to your specified database. All you should need to do is type the information you have about your database into the corresponding fields and you should be good to go.
Linux Exclusive CMS’s
Magento 1
Database connection strings for Magento 1 are located at /<Magento Install Directory>/app/etc/local.xml. Make sure you go to the directory where your Magento installation is located before trying to find the file local.xml.
The file once opened should contain a section like this:
<connection> <host> <![CDATA[your_database_hostname]]> </host> <username> <![CDATA[your_database_username]]> </username> <password> <![CDATA[your_database_password]]> </password> <dbname> <![CDATA[your_database_name]]> </dbname> <active> 1 </active> </connection>
You then need to input the information you have into the corresponding fields.
Once you have done so, save the file and now your Magento 1 installation should be connecting to your chosen database.
Magento 2
Magento 2 is similar to Magento 1, however the file you’re looking for to access the database connection strings is instead located at: /<Magento Install Directory>/app/etc/env.php and you need to open the env.php file.
The file, once opened, should contain a section like this:
'db' => [ 'table_prefix' => 'your_database_prefix', 'connection' => [ 'default' => [ 'host' => 'your_database_host', 'dbname' => 'your_database_name', 'username' => 'your_database_username', 'password' => 'your_database_password', 'active' => '1', ], ], ],
Similar to Magento 1, you just need to input the information you have into the corresponding fields.
Once you have done so, feel free to save the file and your Magento 2 installation should be able to connect to the correct database.
Windows Exclusive CMS’s
Umbraco
By default, your Umbraco installation will use SQL CE and will be directed to a flat file labelled as Umbraco.sdf in the App_Data folder within your domain’s directory. This file contains your whole database used by Umbraco. It is directed to this via the web.config file, which can be located in the directory where your Umbraco installation resides.
The string you are looking for within your web.config file in relation to your Umbraco.sdf file can be found under the <connectionStrings> section below:
<connectionStrings> <remove name="umbracoDbDSN" /> <add name="umbracoDbDSN" connectionString="Data Source=|DataDirectory|\Umbraco.sdf;Flush Interval=1;" providerName="System.Data.SqlServerCe.4.0" /> <!-- Important: If you're upgrading Umbraco, do not clear the connection string / provider name during your web.config merge. --> </connectionStrings>
If you’re wanting to continue to use SQL CE and keep your database in a singular file, all you need to do when migrating sites is make sure the Umbraco.sdf file stays in the same location. As long as you don’t move it around directories, Umbraco should still be able to connect to your database without any configuration required. Just make sure when moving this file from site-to-site , you make a backup, as your entire database for your site resides in it.
If you have set up Umbraco to use MSSQL on our database servers, then you should have code that looks like this:
<connectionStrings> <remove name="umbracoDbDSN" /> <add name="umbracoDbDSN" connectionString="server={your_database_host};database={your_database_name};user id={your_database_username};password={your_database_password}" providerName="System.Data.SqlClient" /> <!-- Important: If you're upgrading Umbraco, do not clear the connection string / provider name during your web.config merge. --> </connectionStrings>
When migrating, you simply need to alter these strings with the information that corresponds with your database. E.g. server={your_database_host} will be the name of the server where your database is located (e.g. mssql.pipeten.co.uk).
DotNetNuke (DNN)
DotNetNuke (DNN) has two options when it comes to how it uses a database. The first version is via SQL Server Express, which stores the database contents in a .mdf file. This .mdf can be called whatever you wish, however by default, it is often labelled Database.mdf.
The second way is via your standard MS SQL Server which requires the usual details for connecting to the database. These are shown at the very top of this guide. These details will match with an MS SQL database you have already set up previously.
You can find both forms of database connection strings already inputted into the web.config file. Which you use is determined by which choice of SQL Server version you chose upon installation.
For SQL Server Express, your database connection string should look like this and needs to have this section uncommented:
<connectionStrings> <!-- Connection String for SQL Server 2008/2012 Express --> <add name="SiteSqlServer" connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|Database.mdf;" providerName="System.Data.SqlClient"/> </connectionStrings>
As long as you keep the .mdf file in the same directory/location as it was in before and also haven’t renamed it, you shouldn’t have to alter any code within the connection strings upon migration of the site.
For standard SQL Server, should be in a similar format to this, with you needing to make sure it’s this part that is uncommented:
<connectionStrings> <!-- Connection String for SQL Server 2008/2012 --> <add name="SiteSqlServer" connectionString="Server=your_database_host;Database=your_database_name;user id=your_database_username;password=your_database_password" providerName="System.Data.SqlClient"/> </connectionStrings>
You will only need to alter these if you have chosen to use our MS SQL database servers, in which case upon migration, you will need to alter the appropriate fields to match the new details. You can find these out via the links at the very top of this guide.
Classification: Public
Last saved: 2019/08/16 at 14:01 by Jamie