Search code examples
mysqlruby-on-railsmysql2mariadb

Use MariaDB instead of MySQL in my Rails project


How can I use MariaDB instead of MySQL in my Rails project?

When I try to install mysql2 gem it returns error,because mysqlclient was not found.

Here some solution, but I didn't found any libmariadbd-dev package on my openSUSE 12.3.


Solution

  • It doesn't look like openSUSE has a MariaDB client development package. You must install the libmysqlclient-devel package package. Since MariaDB is tagged as a drop in replacement for MySQL, it would have to support the MySQL clients, though you may lose tiny bits of MariaDB improvements.

    It appears that the mysql2 gem should function with the MariaDB client libraries. Other options are hoping the mariadb-client package is enough, find a 3rd party package for the libraries or installing them yourself.

    Update There is now an MariaDB repository for openSUSE. It includes a development package, and very good instructions. Place the following in a file under /etc/zypp/repos.d/

    # MariaDB 10.1 openSUSE repository list - created 2015-10-20 16:37 UTC
    # http://mariadb.org/mariadb/repositories/
    [mariadb]
    name = MariaDB
    baseurl = http://yum.mariadb.org/10.1/opensuse13-amd64
    gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
    gpgcheck=1
    

    Now you can run zypper install MariaDB-client MariaDB-devel


    Your question isn't about Ubuntu, but I'm sure a lot of people Googling Ubuntu (or its derivatives like Mint) will land on this page. In Ubuntu, you have to install all the packages using the MariaDB Foundation's ppa, but they include all the development libraries and support the 5.5, 10.0 and 10.1 releases. Then you can install packages such as mariadb-server, mariadb-client, libmariadbclient-dev, and libmariadbclient-dev:i386 (32-bit client).

    The instructions are simple and detailed on the site. For example, installing just the 10.1 dev libraries in Ubuntu 14.04

    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 http://mirrors.syringanetworks.net/mariadb/repo/10.1/ubuntu trusty main'
    sudo apt-get update
    sudo apt-get install libmariadbclient-dev