Can't start MariaDB after installing next to MySQL on Ubuntu 14.04

I installed MariaDB 10.0.14 following the official instructions at mariadb.com line by line.

I am running Ubuntu 14.04 (updated from 12.04) and the MySQL server is already installed. When I try to start mariadb, I first stop the MySQL service:

$ sudo /etc/init.d/mysql stop
$ sudo /etc/init.d/mariadb start

      

but nothing happens. Obviously, 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:

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 cannot figure out why I am getting permissions denied when starting the service. I created a new system group and user called mariadb which should handle this as instructed.

Perhaps I should grant full r / w permissions to the my / opt / mariadb-data directory, but I'm not sure if this is a good approach. What should I do?

+3


source to share


2 answers


Are you sure you have configured the -defaults-file = / opt / mariadb-data / my.cnf options in /etc/init.d/mariadb correctly?

The problem is that mysqld is still trying to create a .pid file in / var / run / mysql and not in / opt / mariadb. The / var / run / mysql directory belongs to the system user "mysql", not the user "mariadb" you created as instructed.



And the / var / run / mysql option can only come from the system / etc / mysql / my.cnf file, which is read by mysqld_safe / mysqld by default IF it is overridden by --defaults-file = ...

Also note that the --defaults file must be the very first command line option

+1


source


Even though @ hartmut-holzgraefe gives a good solution in his answer, I decided to try a different approach. Since it works very well and independent of my MySQL server, I thought I could share it with everyone.

Moving from the Docker container for MariaDB ( tutum / mariadb ) turns out to be a faster and possibly cleaner solution than trying to install it alongside MySQL.

Actions

Steps to run mariadb via docker:

  • Install Docker
  • Pull whatever MariaDB version you want from tutum-docker-mariadb (10.1 in my case)
  • Build an image and run it to configure the container




Commands

The commands for step 3 are listed in the README of the repo. I will only focus on the fact that you can explicitly specify the hostname and port of your machines, for example:

# build the image
docker build -t tutum/mariadb .

# run it
docker run -d -p 127.0.0.1:3307:3306 -e MARIADB_PASS="mypass" tutum/mariadb

# connect to mariadb
mysql -uadmin -pmypass -h127.0.0.1 -P3307

      




  • admin - the default user created when the Container is first started
  • mypass is a special password to override the random password that is initially generated (otherwise you will have to use docker logs to get it)
  • 127.0.0.1:3307:3306 means you bind port 3306 inside the container to 3307 on your localhost.
+2


source







All Articles