26 June 2016

Updating from deprecated PHP 5.6 PPA

I'm running an Ubuntu 14.04.4 LTS server with Apache2 and phpMyAdmin running several Drupal 7 and 8 sites. I saw this message when getting updates and this is how I updated my system to the new PHP5.6 PPA:

Following the instructions from root I ran these commands:
LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php5
apt-get dist-upgrade

This got PHP 7.0 on my system. To get PHP 5.6 I ran this:
apt-get install php5.6
I later found that I needed these extensions:
apt-get install php5.6-mysql
apt-get install php5.6-xml
apt-get install php5.6-gd

apt-get install php5.6-mbstring
apt-get install php5.6-mcrypt
apt-get install php5.6-zip

Apache was still running the old version, I disabled the php5 module, enabled php5.6 and restarted:
a2dismod php5
a2enmod php5.6
service apache2 restart

I had changed my PHP.INI file - which was in /etc/php5/apache2/php.ini
So I did similar changes in here /etc/php/5.6/apache2/php.ini
and restarted: service apache2 restart

The command line php was now running 7.0 so I changed it using this command:
update-alternatives --config php

Thanks to Ondřej Surý at https://launchpad.net/~ondrej/+archive/ubuntu/php

04 June 2016

Microsoft SQL Server Express copying tables using Identity Insert

I recently needed to copy some tables from one SQL Server Express database to another - as part of a server move on a CMS where I wanted a fresh install to clean things up. I needed to copy several tables across, keeping the primary keys the same so as to ensure the data integrity. Here's what I had to do to do the transfer:
  1. Ensure that SQL Server Management Studio and Import and Export Data tools are installed.
  2. Ensure that the SQL Server (SQLEXPRESS) and SQL Server Browser services are started.
  3. You probably need to make sure that your login has admin access to SQL Server Express.
  4. I started by copying the MDF and LDF files (for both databases) to a new location so I can work with a clean copy that won't be used by something else
  5. Open Management Studio and connect to (local)\SQLEXPRESS
  6. Click right on Databases then select Attach, then click Add and choose your MDF
  7. Amend "Attach as" if desired and check the MDF and LDF file paths below, then click OK
  8. Do the same for the other database
  9. Open the Import and Export Wizard
  10. Select the SQL Server Native Client
  11. Enter (local)\SQLEXPRESS in the Server name box
  12. Choose the required source database below, then click Next
  13. Do the same to choose the destination database
  14. Select "Copy data from one or more tables and views"
  15. Select which tables you wish to copy
  16. For each table, click Edit Mappings.
  17. Ensure that "Enable identity insert" is ticked
  18. Choose the appropriate action on the left, eg "Delete rows in destination table", then click OK
  19. Remember: do this for each table
  20. Click Next, then Next then Finish
  21. Open up the destination database in Management Studio to confirm that the tables have got the correct data.
  22. You had probably best use Tasks+Detach in Management Studio to make sure that all connections are dropped before copy the destination database files into the desired location
Not so bad after all. To celebrate, here's a photo of some nicely padded swallow eggs: