1

My goal is to have MariaDB 10.1 and MySQL 8 on the same Ubuntu 18.04 server.

I was able to setup MySQL 8 successfully, and got stuck almost at the end while setting up MariaDB following this guide:

https://mariadb.com/kb/en/library/installing-mariadb-alongside-mysql/

Basically this is what I did:

  1. downloaded mariadb for linux
  2. copied the extracted folder to /opt/mariadb
  3. created /opt/mariadb-data folder
  4. chown'ed by mariadb user (freshly created)
  5. copied a my.cnf to /opt/mariadb-data and edited port number and user, basedir and datadir. copied a mysql.service file to /etc/init.d/mariadb and edited it
  6. ran setup script
  7. tried starting, and got this error:
Warning: The unit file, source configuration file or drop-ins of mariadb.service changed on disk. Run 'systemctl daemon-reload' to reload
● mariadb.service - LSB: start and stop MySQL
   Loaded: loaded (/etc/init.d/mariadb; generated)
   Active: failed (Result: exit-code) since Thu 2019-08-29 23:27:12 EDT; 2s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 35976 ExecStop=/etc/init.d/mariadb stop (code=exited, status=0/SUCCESS)
  Process: 36610 ExecStart=/etc/init.d/mariadb start (code=exited, status=1/FAILURE)
    Tasks: 28 (limit: 4563)
   CGroup: /system.slice/mariadb.service
           ├─33699 /bin/sh /opt/mariadb/bin/mysqld_safe --defaults-file=/opt/mariadb-data/my.cnf --datadir=/opt/mariadb/data --pid-file=/o
           └─33830 /opt/mariadb/bin/mysqld --defaults-file=/opt/mariadb-data/my.cnf --basedir=/opt/mariadb --datadir=/opt/mariadb/data --p

Aug 29 23:27:11 dev03.example.com systemd[1]: Starting LSB: start and stop MySQL...
Aug 29 23:27:11 dev03.example.com mariadb[36610]: Starting MySQL
Aug 29 23:27:11 dev03.example.com mariadb[36610]: .190829 23:27:11 mysqld_safe Logging to '/opt/mariadb-data/dev03.example.com.err'.
Aug 29 23:27:11 dev03.example.com mariadb[36610]: 190829 23:27:11 mysqld_safe A mysqld process already exists
Aug 29 23:27:12 dev03.example.com mariadb[36610]:  *
Aug 29 23:27:12 dev03.example.com systemd[1]: mariadb.service: Control process exited, code=exited status=1
Aug 29 23:27:12 dev03.example.com systemd[1]: mariadb.service: Failed with result 'exit-code'.
Aug 29 23:27:12 dev03.example.com systemd[1]: Failed to start LSB: start and stop MySQL.


Here's the important part of the configuration I've set for my.cnf following the tutorial link.

Create a new my.cnf in /opt/mariadb from support files:
[root@mariadb-near-mysql opt]# cp mariadb/support-files/my-medium.cnf mariadb-data/my.cnf
[root@mariadb-near-mysql opt]# chown mariadb:mariadb mariadb-data/my.cnf
Edit the file /opt/mariadb-data/my.cnf and add custom paths, socket, port, user and the most important of all: data directory and base directory. Finally the file should have at least the following:
[client]
port        = 3307
socket      = /opt/mariadb-data/mariadb.sock

[mysqld]
datadir         = /opt/mariadb-data
basedir         = /opt/mariadb
port        = 3307
socket      = /opt/mariadb-data/mariadb.sock
user            = mariadb
Copy the init.d script from support files in the right location:
[root@mariadb-near-mysql opt]# cp mariadb/support-files/mysql.server /etc/init.d/mariadb
[root@mariadb-near-mysql opt]# chmod +x /etc/init.d/mariadb
Edit /etc/init.d/mariadb replacing mysql with mariadb as below:
- # Provides: mysql
+ # Provides: mariadb
- basedir=
+ basedir=/opt/mariadb
- datadir=
+ datadir=/opt/mariadb-data
- lock_file_path="$lockdir/mysql"
+ lock_file_path="$lockdir/mariadb"
The trickiest part will be the last changes to this file. You need to tell mariadb to use only one cnf file. In the start section after $bindir/mysqld_safe add --defaults-file=/opt/mariadb-data/my.cnf. Finally the lines should look like:

# Give extra arguments to mysqld with the my.cnf file. This script
# may be overwritten at next upgrade.
$bindir/mysqld_safe --defaults-file=/opt/mariadb-data/my.cnf --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null 2>&1 &
The same change needs to be made to the mysqladmin command below in the wait_for_ready() function so that the mariadb start command can properly listen for the server start. In the wait_for_ready() function, after $bindir/mysqladmin add --defaults-file=/opt/mariadb-data/my.cnf. The lines should look like:

What can I do to change the mysqld process name for MariaDB or can I avoid conflict another way?

  • 1
    In /etc/init.d/mariadb setting the pid file as /opt/mariadb-data/mariadb.pid helped but now systemstartctl hangs... CTRL+C helps but if I run it twice then two processes show up in ps aux for mariadb (unlike mysql) – FADSDEV Aug 30 '19 at 5:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.