title: MariaDB on Mac OS X Sierra via Homebrew
body: <p>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 <code>mysql_install_db</code> manually either. Everything is up to date and I have tried multiple times.</p>
  
  <p>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 <code>mysql.user</code> was corrupt. Running <code>optimize</code>/<code>analyze</code>/<code>repair</code> didn't seem to do anything. Also not sure what was done differently to allow MariaDB to start that one time...</p>
  
  <p>The common error seems to be <code>mysqld got signal 4</code> which makes me think that there is an incompatibility between MariaDB and the <code>gcc</code>?</p>
  
  <p>Any help greatly appreciated.</p>
  
  <p><strong>Install MariaDB</strong></p>
  
  <p>Fails to run the post-install step.</p>
  
  <pre><code>&gt; brew install mariadb
  ==&gt; 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
  ==&gt; Pouring mariadb-10.1.18.sierra.bottle.tar.gz
  ==&gt; Using the sandbox
  ==&gt; /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&gt; /usr/local/Cellar/mariadb/10.1.18/bin/mysql -u root mysql
      mysql&gt; 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`
  ==&gt; 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
  ==&gt; Summary
    /usr/local/Cellar/mariadb/10.1.18: 574 files, 136.6M
  </code></pre>
  
  <p><strong>Run Post Install via Homebrew</strong></p>
  
  <pre><code>&gt; brew postinstall mariadb
  ==&gt; Using the sandbox
  ==&gt; /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&gt; /usr/local/Cellar/mariadb/10.1.18/bin/mysql -u root mysql
      mysql&gt; 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
  </code></pre>
  
  <p><strong>Manually run <code>mysql_install_db</code></strong></p>
  
  <pre><code>&gt; 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&gt; /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&gt; /usr/local/Cellar/mariadb/10.1.18/bin/mysqld --skip-grant --general-log &amp;
  
  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&gt; /usr/local/Cellar/mariadb/10.1.18/bin/mysql -u root mysql
      mysql&gt; 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
  </code></pre>
  
  <p><strong>Starting DB</strong></p>
  
  <pre><code>&gt; mysql.server start
  Starting MySQL
  .161107 10:58:10 mysqld_safe Logging to '/usr/local/var/mysql/MacBook-Pro.local.err'.
   ERROR!
  
  &gt; 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
  </code></pre>
  
  <hr>
  
  <h2><strong>System Information</strong></h2>
  
  <p><strong><em>OSX</em></strong></p>
  
  <pre><code>10.12.1
  </code></pre>
  
  <p><strong><em>Homebrew</em></strong></p>
  
  <pre><code>&gt; brew -v
  Homebrew 1.0.9
  Homebrew/homebrew-core (git revision 3a20; last commit 2016-11-06)
  
  &gt; brew update
  Already up-to-date.
  
  &gt; brew doctor
  Your system is ready to brew.
  </code></pre>
  
  <p><strong><em>GCC</em></strong></p>
  
  <pre><code>&gt; 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
  </code></pre>
  
  <p><strong><em>MariaDB Uninstall</em></strong></p>
  
  <pre><code>brew remove mariadb
  rm -rf /usr/local/var/mysql
  brew cleanup
  </code></pre>