MariaDB on Mac OS X Sierra via Homebrew

11,670

In the long tradition of working on a problem for days and then fixing it right after posting a question... I was able to install MariaDB using Homebrew on OSX Sierra.

I was about to remove and reinstall XCode and the command line tools but for some reason decided to make sure that it was pointed to the correct path and ran:

sudo xcode-select --switch /Applications/Xcode.app

At the same time I zeroed in on the ssleay_rand_bytes and my_random_bytes part of the stacktrace and thought maybe openssl wasn't installed (it was) but then reinstalled it using homebrew. Then I decided to try one more time before killing XCode, and it worked...

openssl already installed

> brew install openssl
Warning: openssl-1.0.2j already installed

reinstall openssl

> brew reinstall openssl
==> Reinstalling openssl with --universal
==> Using the sandbox
==> Downloading https://www.openssl.org/source/openssl-1.0.2j.tar.gz
######################################################################## 100.0%
==> make clean
==> perl ./Configure --prefix=/usr/local/Cellar/openssl/1.0.2j --openssldir=/usr/local/etc/openssl no-ssl2 zlib-dynamic shared enable-cms darwin64-x86_64-cc enable-ec_nistp_6
==> make depend
==> make
xcode-select==> make test
==> make clean
==> perl ./Configure --prefix=/usr/local/Cellar/openssl/1.0.2j --openssldir=/usr/local/etc/openssl no-ssl2 zlib-dynamic shared enable-cms darwin-i386-cc
==> make depend
==> make
==> make test
==> make install MANDIR=/usr/local/Cellar/openssl/1.0.2j/share/man MANSUFFIX=ssl
==> lipo -create build-x86_64/libcrypto.1.0.0.dylib build-i386/libcrypto.1.0.0.dylib -output /usr/local/Cellar/openssl/1.0.2j/lib/libcrypto.1.0.0.dylib
==> lipo -create build-x86_64/libcrypto.a build-i386/libcrypto.a -output /usr/local/Cellar/openssl/1.0.2j/lib/libcrypto.a
==> lipo -create build-x86_64/libssl.1.0.0.dylib build-i386/libssl.1.0.0.dylib -output /usr/local/Cellar/openssl/1.0.2j/lib/libssl.1.0.0.dylib
==> lipo -create build-x86_64/libssl.a build-i386/libssl.a -output /usr/local/Cellar/openssl/1.0.2j/lib/libssl.a
==> lipo -create build-x86_64/engines/lib4758cca.dylib build-i386/engines/lib4758cca.dylib -output /usr/local/Cellar/openssl/1.0.2j/lib/engines/lib4758cca.dylib
==> lipo -create build-x86_64/engines/libaep.dylib build-i386/engines/libaep.dylib -output /usr/local/Cellar/openssl/1.0.2j/lib/engines/libaep.dylib
==> lipo -create build-x86_64/engines/libatalla.dylib build-i386/engines/libatalla.dylib -output /usr/local/Cellar/openssl/1.0.2j/lib/engines/libatalla.dylib
==> lipo -create build-x86_64/engines/libcapi.dylib build-i386/engines/libcapi.dylib -output /usr/local/Cellar/openssl/1.0.2j/lib/engines/libcapi.dylib
==> lipo -create build-x86_64/engines/libchil.dylib build-i386/engines/libchil.dylib -output /usr/local/Cellar/openssl/1.0.2j/lib/engines/libchil.dylib
==> lipo -create build-x86_64/engines/libcswift.dylib build-i386/engines/libcswift.dylib -output /usr/local/Cellar/openssl/1.0.2j/lib/engines/libcswift.dylib
==> lipo -create build-x86_64/engines/libgmp.dylib build-i386/engines/libgmp.dylib -output /usr/local/Cellar/openssl/1.0.2j/lib/engines/libgmp.dylib
==> lipo -create build-x86_64/engines/libgost.dylib build-i386/engines/libgost.dylib -output /usr/local/Cellar/openssl/1.0.2j/lib/engines/libgost.dylib
==> lipo -create build-x86_64/engines/libnuron.dylib build-i386/engines/libnuron.dylib -output /usr/local/Cellar/openssl/1.0.2j/lib/engines/libnuron.dylib
==> lipo -create build-x86_64/engines/libpadlock.dylib build-i386/engines/libpadlock.dylib -output /usr/local/Cellar/openssl/1.0.2j/lib/engines/libpadlock.dylib
==> lipo -create build-x86_64/engines/libsureware.dylib build-i386/engines/libsureware.dylib -output /usr/local/Cellar/openssl/1.0.2j/lib/engines/libsureware.dylib
==> lipo -create build-x86_64/engines/libubsec.dylib build-i386/engines/libubsec.dylib -output /usr/local/Cellar/openssl/1.0.2j/lib/engines/libubsec.dylib
==> lipo -create build-x86_64/openssl build-i386/openssl -output /usr/local/Cellar/openssl/1.0.2j/bin/openssl
==> Caveats
A CA file has been bootstrapped using certificates from the SystemRoots
keychain. To add additional certificates (e.g. the certificates added in
the System keychain), place .pem files in
  /usr/local/etc/openssl/certs

and run
  /usr/local/opt/openssl/bin/c_rehash

This formula is keg-only, which means it was not symlinked into /usr/local.

Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/openssl/lib
    CPPFLAGS: -I/usr/local/opt/openssl/include
    PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig

==> Summary
🍺  /usr/local/Cellar/openssl/1.0.2j: 1,696 files, 17.3M, built in 11 minutes 1 second

install mariadb

> brew install mariadb
==> Downloading https://homebrew.bintray.com/bottles/mariadb-10.1.18.sierra.bottle.tar.gz
Already downloaded: /Users/username/Library/Caches/Homebrew/mariadb-10.1.18.sierra.bottle.tar.gz
==> Pouring mariadb-10.1.18.sierra.bottle.tar.gz
==> Using the sandbox
==> /usr/local/Cellar/mariadb/10.1.18/bin/mysql_install_db --verbose --user=username --basedir=/usr/local/Cellar/mariadb/10.1.18 --datadir=/usr/local/var/mysql --tmpdir=/
==> Caveats
A "/etc/my.cnf" from another install may interfere with a Homebrew-built
server starting up correctly.

To connect:
    mysql -uroot

To have launchd start mariadb now and restart at login:
  brew services start mariadb
Or, if you don't want/need a background service you can just run:
  mysql.server start
==> Summary
🍺  /usr/local/Cellar/mariadb/10.1.18: 574 files, 136.6M

connect to mariadb

> mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.1.18-MariaDB Homebrew

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> exit
Bye
Share:
11,670
doublesharp
Author by

doublesharp

Personal Site/Blog: https://www.justinsilver.com Doublesharp Consulting: https://www.doublesharp.com Secret Party: https://www.secretparty.io

Updated on June 04, 2022

Comments

  • doublesharp
    doublesharp almost 2 years

    After updating to Sierra, MariaDB would no long start on my system. As it did not contain critical data, I removed it and attempted to reinstall via homebrew, however the post-install fails and I am unable to run mysql_install_db manually either. Everything is up to date and I have tried multiple times.

    I was able to start the service and even create a new database and user, but when trying to set the user password the database would crash saying that mysql.user was corrupt. Running optimize/analyze/repair didn't seem to do anything. Also not sure what was done differently to allow MariaDB to start that one time...

    The common error seems to be mysqld got signal 4 which makes me think that there is an incompatibility between MariaDB and the gcc?

    Any help greatly appreciated.

    Install MariaDB

    Fails to run the post-install step.

    > brew install mariadb
    ==> Downloading https://homebrew.bintray.com/bottles/mariadb-10.1.18.sierra.bottle.tar.gz
    Already downloaded: /Users/username/Library/Caches/Homebrew/mariadb-10.1.18.sierra.bottle.tar.gz
    ==> Pouring mariadb-10.1.18.sierra.bottle.tar.gz
    ==> Using the sandbox
    ==> /usr/local/Cellar/mariadb/10.1.18/bin/mysql_install_db --verbose --user=username --basedir=/usr/local/Cellar/mariadb/10.1.18 --datadir=/usr/local/var/mysql --tmpdir=/
    Last 15 lines from /Users/username/Library/Logs/Homebrew/mariadb/post_install.01.mysql_install_db:
    
        shell> /usr/local/Cellar/mariadb/10.1.18/bin/mysql -u root mysql
        mysql> show tables;
    
    Try 'mysqld --help' if you have problems with paths.  Using
    --general-log gives you a log in /usr/local/var/mysql that may be helpful.
    
    The latest information about mysql_install_db is available at
    https://mariadb.com/kb/en/installing-system-tables-mysql_install_db
    MariaDB is hosted on launchpad; You can find the latest source and
    email lists at http://launchpad.net/maria
    
    Please check all of the above before submitting a bug report
    at http://mariadb.org/jira
    
    Warning: The post-install step did not complete successfully
    You can try again using `brew postinstall mariadb`
    ==> Caveats
    A "/etc/my.cnf" from another install may interfere with a Homebrew-built
    server starting up correctly.
    
    To connect:
        mysql -uroot
    
    To have launchd start mariadb now and restart at login:
      brew services start mariadb
    Or, if you don't want/need a background service you can just run:
      mysql.server start
    ==> Summary
    🍺  /usr/local/Cellar/mariadb/10.1.18: 574 files, 136.6M
    

    Run Post Install via Homebrew

    > brew postinstall mariadb
    ==> Using the sandbox
    ==> /usr/local/Cellar/mariadb/10.1.18/bin/mysql_install_db --verbose --user=username --basedir=/usr/local/Cellar/mariadb/10.1.18 --datadir=/usr/local/var/mysql --tmpdir=/
    Last 15 lines from /Users/username/Library/Logs/Homebrew/mariadb/post_install.01.mysql_install_db:
    
        shell> /usr/local/Cellar/mariadb/10.1.18/bin/mysql -u root mysql
        mysql> show tables;
    
    Try 'mysqld --help' if you have problems with paths.  Using
    --general-log gives you a log in /usr/local/var/mysql that may be helpful.
    
    The latest information about mysql_install_db is available at
    https://mariadb.com/kb/en/installing-system-tables-mysql_install_db
    MariaDB is hosted on launchpad; You can find the latest source and
    email lists at http://launchpad.net/maria
    
    Please check all of the above before submitting a bug report
    at http://mariadb.org/jira
    
    
    READ THIS: https://git.io/brew-troubleshooting
    

    Manually run mysql_install_db

    > mysql_install_db --general-log
    Installing MariaDB/MySQL system tables in '/usr/local/var/mysql' ...
    2016-11-07 10:56:36 140735707972544 [Warning] 'THREAD_CONCURRENCY' is deprecated and will be removed in a future release.
    2016-11-07 10:56:36 140735707972544 [Note] /usr/local/Cellar/mariadb/10.1.18/bin/mysqld (mysqld 10.1.18-MariaDB) starting as process 32902 ...
    2016-11-07 10:56:36 7fff95e183c0 InnoDB: Warning: Using innodb_additional_mem_pool_size is DEPRECATED. This option may be removed in future releases, together with the option innodb_use_sys_malloc and with the InnoDB's internal memory allocator.
    2016-11-07 10:56:36 140735707972544 [Note] InnoDB: Using mutexes to ref count buffer pool pages
    2016-11-07 10:56:36 140735707972544 [Note] InnoDB: The InnoDB memory heap is disabled
    2016-11-07 10:56:36 140735707972544 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
    2016-11-07 10:56:36 140735707972544 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
    2016-11-07 10:56:36 140735707972544 [Note] InnoDB: Compressed tables use zlib 1.2.8
    2016-11-07 10:56:36 140735707972544 [Note] InnoDB: Using SSE crc32 instructions
    2016-11-07 10:56:36 140735707972544 [Note] InnoDB: Initializing buffer pool, size = 2.0G
    2016-11-07 10:56:37 140735707972544 [Note] InnoDB: Completed initialization of buffer pool
    161107 10:56:37 [ERROR] mysqld got signal 4 ;
    This could be because you hit a bug. It is also possible that this binary
    or one of the libraries it was linked against is corrupt, improperly built,
    or misconfigured. This error can also be caused by malfunctioning hardware.
    
    To report this bug, see https://mariadb.com/kb/en/reporting-bugs
    
    We will try our best to scrape up some info that will hopefully help
    diagnose the problem, but since we have already crashed, 
    something is definitely wrong and this may fail.
    
    Server version: 10.1.18-MariaDB
    key_buffer_size=33554432
    read_buffer_size=2097152
    max_used_connections=0
    max_threads=102
    thread_count=0
    It is possible that mysqld could use up to 
    key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 1079322 K  bytes of memory
    Hope that's ok; if not, decrease some variables in the equation.
    
    Thread pointer: 0x0x0
    Attempting backtrace. You can use the following information to find out
    where mysqld died. If you see no messages after this, something went
    terribly wrong...
    stack_bottom = 0x0 thread_stack 0x3c000
    0   mysqld                              0x00000001076e62dc my_print_stacktrace + 60
    0   mysqld                              0x00000001071c6b4e handle_fatal_signal + 632
    0   libsystem_platform.dylib            0x00007fff8d307bba _sigtramp + 26
    0   libcrypto.1.0.0.dylib               0x000000010886cebb OPENSSL_ia32cap_P + 8019
    0   libcrypto.1.0.0.dylib               0x000000010878456d ssleay_rand_bytes + 248
    0   mysqld                              0x00000001076f5200 my_random_bytes + 32
    0   mysqld                              0x00000001075b2790 _Z27fil_space_create_crypt_data16fil_encryption_tj + 184
    0   mysqld                              0x000000010769cda6 _Z34innobase_start_or_create_for_mysqlv + 4566
    0   mysqld                              0x00000001075f28aa _ZL13innobase_initPv + 3046
    0   mysqld                              0x00000001071c76de _Z24ha_initialize_handlertonP13st_plugin_int + 94
    0   mysqld                              0x000000010732dd19 _ZL17plugin_initializeP11st_mem_rootP13st_plugin_intPiPPcb + 351
    0   mysqld                              0x000000010732d9c9 _Z11plugin_initPiPPci + 2767
    0   mysqld                              0x0000000107270c0a _ZL22init_server_componentsv + 1807
    0   mysqld                              0x000000010726f017 _Z11mysqld_mainiPPc + 10571
    0   libdyld.dylib                       0x00007fff8d0fa255 start + 1
    0   ???                                 0x000000000000000a 0x0 + 10
    The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
    information that should help you find out what is causing the crash.
    
    Installation of system tables failed!  Examine the logs in
    /usr/local/var/mysql for more information.
    
    The problem could be conflicting information in an external
    my.cnf files. You can ignore these by doing:
    
        shell> /usr/local/Cellar/mariadb/10.1.18/scripts/scripts/mysql_install_db --defaults-file=~/.my.cnf
    
    You can also try to start the mysqld daemon with:
    
        shell> /usr/local/Cellar/mariadb/10.1.18/bin/mysqld --skip-grant --general-log &
    
    and use the command line tool /usr/local/Cellar/mariadb/10.1.18/bin/mysql
    to connect to the mysql database and look at the grant tables:
    
        shell> /usr/local/Cellar/mariadb/10.1.18/bin/mysql -u root mysql
        mysql> show tables;
    
    Try 'mysqld --help' if you have problems with paths.  Using
    --general-log gives you a log in /usr/local/var/mysql that may be helpful.
    
    The latest information about mysql_install_db is available at
    https://mariadb.com/kb/en/installing-system-tables-mysql_install_db
    MariaDB is hosted on launchpad; You can find the latest source and
    email lists at http://launchpad.net/maria
    
    Please check all of the above before submitting a bug report
    at http://mariadb.org/jira
    

    Starting DB

    > mysql.server start
    Starting MySQL
    .161107 10:58:10 mysqld_safe Logging to '/usr/local/var/mysql/MacBook-Pro.local.err'.
     ERROR!
    
    > cat MacBook-Pro.local.err 
    161107 10:59:15 mysqld_safe Starting mysqld daemon with databases from /usr/local/var/mysql
    2016-11-07 10:59:15 140735707972544 [Warning] 'THREAD_CONCURRENCY' is deprecated and will be removed in a future release.
    2016-11-07 10:59:15 140735707972544 [Note] /usr/local/Cellar/mariadb/10.1.18/bin/mysqld (mysqld 10.1.18-MariaDB) starting as process 33473 ...
    2016-11-07 10:59:15 140735707972544 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive
    2016-11-07 10:59:15 140735707972544 [Note] Using unique option prefix 'myisam_recover' is error-prone and can break in the future. Please use the full name 'myisam-recover-options' instead.
    2016-11-07 10:59:15 7fff95e183c0 InnoDB: Warning: Using innodb_additional_mem_pool_size is DEPRECATED. This option may be removed in future releases, together with the option innodb_use_sys_malloc and with the InnoDB's internal memory allocator.
    2016-11-07 10:59:15 140735707972544 [Note] InnoDB: Using mutexes to ref count buffer pool pages
    2016-11-07 10:59:15 140735707972544 [Note] InnoDB: The InnoDB memory heap is disabled
    2016-11-07 10:59:15 140735707972544 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
    2016-11-07 10:59:15 140735707972544 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
    2016-11-07 10:59:15 140735707972544 [Note] InnoDB: Compressed tables use zlib 1.2.8
    2016-11-07 10:59:15 140735707972544 [Note] InnoDB: Using SSE crc32 instructions
    2016-11-07 10:59:15 140735707972544 [Note] InnoDB: Initializing buffer pool, size = 2.0G
    2016-11-07 10:59:15 140735707972544 [Note] InnoDB: Completed initialization of buffer pool
    2016-11-07 10:59:15 140735707972544 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
    2016-11-07 10:59:15 140735707972544 [Note] InnoDB: Setting file ./ibdata1 size to 10 MB
    2016-11-07 10:59:15 140735707972544 [Note] InnoDB: Database physically writes the file full: wait...
    161107 10:59:15 [ERROR] mysqld got signal 4 ;
    This could be because you hit a bug. It is also possible that this binary
    or one of the libraries it was linked against is corrupt, improperly built,
    or misconfigured. This error can also be caused by malfunctioning hardware.
    
    To report this bug, see https://mariadb.com/kb/en/reporting-bugs
    
    We will try our best to scrape up some info that will hopefully help
    diagnose the problem, but since we have already crashed, 
    something is definitely wrong and this may fail.
    
    Server version: 10.1.18-MariaDB
    key_buffer_size=33554432
    read_buffer_size=2097152
    max_used_connections=0
    max_threads=102
    thread_count=0
    It is possible that mysqld could use up to 
    key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 1079322 K  bytes of memory
    Hope that's ok; if not, decrease some variables in the equation.
    
    Thread pointer: 0x0x0
    Attempting backtrace. You can use the following information to find out
    where mysqld died. If you see no messages after this, something went
    terribly wrong...
    stack_bottom = 0x0 thread_stack 0x3c000
    0   mysqld                              0x000000010b9952dc my_print_stacktrace + 60
    0   mysqld                              0x000000010b475b4e handle_fatal_signal + 632
    0   libsystem_platform.dylib            0x00007fff8d307bba _sigtramp + 26
    0   ???                                 0x000000010eb4ae0b 0x0 + 4541689355
    0   libcrypto.1.0.0.dylib               0x000000010ca2d56d ssleay_rand_bytes + 248
    0   mysqld                              0x000000010b9a4200 my_random_bytes + 32
    0   mysqld                              0x000000010b861790 _Z27fil_space_create_crypt_data16fil_encryption_tj + 184
    0   mysqld                              0x000000010b94bda6 _Z34innobase_start_or_create_for_mysqlv + 4566
    0   mysqld                              0x000000010b8a18aa _ZL13innobase_initPv + 3046
    0   mysqld                              0x000000010b4766de _Z24ha_initialize_handlertonP13st_plugin_int + 94
    0   mysqld                              0x000000010b5dcd19 _ZL17plugin_initializeP11st_mem_rootP13st_plugin_intPiPPcb + 351
    0   mysqld                              0x000000010b5dc9c9 _Z11plugin_initPiPPci + 2767
    0   mysqld                              0x000000010b51fc0a _ZL22init_server_componentsv + 1807
    0   mysqld                              0x000000010b51e017 _Z11mysqld_mainiPPc + 10571
    0   libdyld.dylib                       0x00007fff8d0fa255 start + 1
    0   ???                                 0x0000000000000009 0x0 + 9
    The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
    information that should help you find out what is causing the crash.
    161107 10:59:16 mysqld_safe mysqld from pid file /usr/local/var/mysql/MacBook-Pro.local.pid ended
    

    System Information

    OSX

    10.12.1
    

    Homebrew

    > brew -v
    Homebrew 1.0.9
    Homebrew/homebrew-core (git revision 3a20; last commit 2016-11-06)
    
    > brew update
    Already up-to-date.
    
    > brew doctor
    Your system is ready to brew.
    

    GCC

    > gcc --version
    Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
    Apple LLVM version 8.0.0 (clang-800.0.42.1)
    Target: x86_64-apple-darwin16.1.0
    Thread model: posix
    InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
    

    MariaDB Uninstall

    brew remove mariadb
    rm -rf /usr/local/var/mysql
    brew cleanup