Centos – Installing MariaDB along with MySQL: Could not find thesqld

centosdatabasemariadb

I am following the instruction on the MariaDB site here all is fine until I get to the part shown below.

[root@squir scripts]# mysql_install_db --defaults-file=/mariadb/data/my.cnf

FATAL ERROR: Could not find mysqld

The following directories were searched:

    /mariadb/mariadb/libexec
    /mariadb/mariadb/sbin
    /mariadb/mariadb/bin

If you compiled from source, you need to run 'make install' to
copy the software into the correct location ready for operation.

If you are using a binary release, you must either be at the top
level of the extracted archive, or pass the --basedir option
pointing to that location.

I wonder if there is the problem with the directory structure that is confusing the install. The documentation is also old, so I am not sure if there is a step missing.

What I Have done So far

  1. Downloaded the MariaDB.tar.gz
  2. Created a directory called /mariadb/
  3. Extracted the MariaDB.tar.gz and created a symbolic link called mariadb
  4. Created a user group and username for MariaDB directory
  5. Created /mariadb/data for storing MariaDB data file (Database)
  6. Copy the pre-written configuration file by this command.

    cp mariadb/support-files/my-medium.cnf mariadb/data/my.cnf

  7. Edited the my.cnf file as per instructed in here

    [client]
    port = 3307
    socket = /mariadb/data/mariadb.sock

    [mysqld]
    datadir = /mariadb/data
    basedir = /mariadb/mariadb
    port = 3307
    socket = /mariadb/data/mariadb.sock
    user = mariadb

  8. Copy the init.d script from support files in the right location:

  9. Edit /etc/init.d/mariadb replacing mysql with mariadb
  10. Run mysql_install_db by explicitly giving it the my.cnf file as argument:

    scripts/mysql_install_db –defaults-file=/opt/mariadb-data/my.cnf

Although on step 10, I can't follow this command. So I did what I stated above and shown the error.

Best Answer

basedir is "base" directory, where all bin lib etc directories reside.

Change basedir = /mariadb/mariadb to basedir = /mariadb.

Also, I guess my.cnf location is somewhere at /mariadb/data/my.cnf, change --defaults-file=/opt/mariadb-data/my.cnf accordingly.

Also, mysql_install_db must run from /mariadb with scripts/mysql_install_db

mysql_install_db will call script from /usr/bin, not the one from /mariadb/scripts/.

It's better to follow standards and install it under /opt/.

Also, be sure selinux is in permissive mode:

getenforce

set "permissive" in /etc/sysconfig/selinux