How to Fix MariaDB 10.1 Installation Error: dpkg Post-Installation Script Failure on Ubuntu 14.04


2 views

When attempting to install MariaDB 10.1 on Ubuntu 14.04 (Trusty), you're encountering a dpkg configuration error during the post-installation phase. The key error messages indicate:

dpkg: error processing package mariadb-server-10.1 (--configure):
subprocess installed post-installation script returned error exit status 1

The error suggests that while the package files were installed correctly, the configuration script failed to execute properly during the final setup phase.

From my experience troubleshooting similar issues, these are the most likely culprits:

  • Remnants of previous MySQL/MariaDB installations not properly purged
  • Permission issues with system directories
  • Conflicting configuration files
  • Insufficient system resources during installation
  • Package manager database corruption

Here's the complete step-by-step solution I've successfully used in production environments:

# First, completely remove all database packages
sudo apt-get remove --purge mariadb* mysql* galera*
sudo apt-get autoremove
sudo apt-get clean

# Remove residual configuration files
sudo rm -rf /var/lib/mysql/
sudo rm -rf /etc/mysql/

# Clean up any remaining dependencies
sudo apt-get -f install
sudo dpkg --configure -a

# Update package lists
sudo apt-get update

# Install with explicit version specification
sudo apt-get install mariadb-server-10.1=10.1.8+maria-1~trusty mariadb-client-10.1=10.1.8+maria-1~trusty

If the problem persists, we need to examine the failing post-install script:

# Check the script location
sudo cat /var/lib/dpkg/info/mariadb-server-10.1.postinst

# Run it manually with debugging
sudo bash -x /var/lib/dpkg/info/mariadb-server-10.1.postinst configure

Common fixes for script failures include:

  • Creating missing directories: sudo mkdir -p /var/run/mysqld
  • Setting correct permissions: sudo chown -R mysql:mysql /var/lib/mysql
  • Ensuring sufficient disk space: df -h

If package installation continues to fail, consider these alternatives:

# Method 1: Install from MariaDB repository
sudo apt-get install software-properties-common
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
sudo add-apt-repository 'deb [arch=amd64,i386] http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.1/ubuntu trusty main'
sudo apt-get update
sudo apt-get install mariadb-server

# Method 2: Binary tarball installation
wget https://downloads.mariadb.org/interstitial/mariadb-10.1.8/bintar-linux-x86_64/mariadb-10.1.8-linux-x86_64.tar.gz
tar -xvzf mariadb-10.1.8-linux-x86_64.tar.gz
cd mariadb-10.1.8-linux-x86_64
sudo ./scripts/mysql_install_db --user=mysql
sudo ./bin/mysqld_safe --user=mysql &

After resolving the installation issues, verify everything works correctly:

# Check service status
sudo systemctl status mariadb

# Test client connection
mysql -u root -p -e "SHOW DATABASES;"

# Verify version
mysql -V

Remember to secure your installation with:

sudo mysql_secure_installation

When attempting to install MariaDB 10.1 on Ubuntu 14.04, you might encounter a particularly stubborn dependency error where the system gets stuck in a configuration loop. The key error messages typically look like this:

dpkg: error processing package mariadb-server-10.1 (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mariadb-server:
 mariadb-server depends on mariadb-server-10.1 (= 10.1.8+maria-1~trusty)

This happens because the post-installation script for mariadb-server-10.1 fails to execute properly, preventing the main mariadb-server package from being configured. Common triggers include:

  • Incomplete removal of previous MySQL/MariaDB installations
  • Permission issues in system directories
  • Broken package states in dpkg
  • Missing dependencies for the init scripts

Here's the complete step-by-step solution I've used successfully on multiple Digital Ocean droplets:

# First, completely clean up existing installations
sudo apt-get remove --purge mariadb-server mariadb-client mariadb-common
sudo apt-get autoremove
sudo apt-get autoclean
sudo rm -rf /var/lib/mysql/
sudo rm -rf /etc/mysql/

# Manually remove any lingering config files
sudo find /etc -name "*mariadb*" | xargs rm -rf
sudo find /etc -name "*mysql*" | xargs rm -rf

# Force reset package states
sudo dpkg --remove --force-remove-reinstreq mariadb-server-10.1
sudo dpkg --remove --force-remove-reinstreq mariadb-server

# Reconfigure package database
sudo dpkg --configure -a
sudo apt-get update
sudo apt-get -f install

# Now install with additional dependencies
sudo apt-get install software-properties-common
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
sudo add-apt-repository 'deb [arch=amd64,i386] http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.1/ubuntu trusty main'
sudo apt-get update
sudo apt-get install mariadb-server

If the problem persists, we need to examine the failing post-installation script. Here's how to debug:

# Find the problematic script
sudo cat /var/lib/dpkg/info/mariadb-server-10.1.postinst

# Run it manually with tracing
sudo bash -x /var/lib/dpkg/info/mariadb-server-10.1.postinst configure

Common script failures often relate to:

  • Systemd vs init.d compatibility issues
  • Missing directories like /run/mysqld
  • Permission problems on /var/lib/mysql

If package installation still fails, consider these alternatives:

# Option 1: Install from MariaDB binaries
wget https://downloads.mariadb.org/interstitial/mariadb-10.1.8/bintar-linux-x86_64/mariadb-10.1.8-linux-x86_64.tar.gz
tar -xvzf mariadb-10.1.8-linux-x86_64.tar.gz
cd mariadb-10.1.8-linux-x86_64
sudo ./scripts/mysql_install_db --user=mysql
sudo ./bin/mysqld_safe --user=mysql &

Or using Docker container:

docker run --name mariadb -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mariadb:10.1

To avoid similar problems when upgrading:

  1. Always backup your databases before major version upgrades
  2. Consider using LTS versions of Ubuntu (14.04 is reaching EOL)
  3. Test package installations in isolated environments first
  4. Monitor MariaDB's official repository for known issues

For production systems, I recommend setting up a proper configuration management system like Ansible:

- name: Ensure MariaDB is properly installed
  apt:
    name: mariadb-server
    state: present
    force: yes
    update_cache: yes
  become: yes
  tags: database