Q:

Cannot start MariaDB after installing alongside MySQL on Ubuntu 14.04

I have installed MariaDB 10.0.14 following the official instructions in mariadb.com line by line.
I'm running Ubuntu 14.04 (upgraded from 12.04) and already have MySQL server installed. When I try to run mariadb I first stop the MySQL service:
$ sudo /etc/init.d/mysql stop
$ sudo /etc/init.d/mariadb start

but nothing happens. Apparently mariadb.sock cannot be created:
$ mysql -e "SELECT VERSION();" --socket=/opt/mariadb-data/mariadb.sock    
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/opt/mariadb-data/mariadb.sock' (111)

My error log is:
141112 13:50:37 mysqld_safe Starting mysqld daemon with databases from /opt/mariadb-data    
141112 13:50:37 [Note] Server socket created on IP: '::'.
141112 13:50:37 [ERROR] mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 13 "Permission denied")
141112 13:50:37 [ERROR] Can't start server: can't create PID file: Permission denied
141112 13:50:37 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

I can't understand why I get permissions denied upon starting the service. I've created new system group and user, both called mariadb, that should handle this, as stated in the instructions.
Perhaps I should grant full r/w rights for my /opt/mariadb-data directory, but I'm not sure this is a good approach. What should I do?

A:

Are you sure you got the --defaults-file=/opt/mariadb-data/my.cnf modifications to the /etc/init.d/mariadb correctly applied?
Problem is that mysqld still tries to create the .pid file in /var/run/mysql, not under /opt/mariadb. The /var/run/mysql directory belongs to the "mysql" system user, not the "mariadb" user you created according to the instructions.
And the /var/run/mysql setting can only come from the system /etc/mysql/my.cnf file, which is read by mysqld_safe / mysqld by default, UNLESS this is overridden with --defaults-file=...
Also note that --defaults-file needs to be the very first command line option

