Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysql 5.6 headaches on Mac OSX

Several of my colleagues and I have recently upgraded from MySQL 5.5 to MySQL 5.6 using homebrew on our Macs to test locally before upgrading our servers. Since this upgrade, we all have been experiencing intermittent MySQL errors when running our rails code:

Lost connection to MySQL server at 'sending authentication information', system error: 32

We have tried re-making our usernames and passwords in our database, and upping the connection timeout, but neither have fixed the problem. The error logs do not mention the issue. The only workaround we have found when we run into the problem is to kill mysql and restart it. I have even noticed this error more recently using mysql -u root -p on the command line. It seems that once I start getting this error, I cannot exceed my current number of connections no matter what username I use. If I close a connection, then I can re-open one.

We have the following environments:

  • some of us: Rails 3.2, Ruby 2, mysql2 0.3.13, MySQL 5.6.12, Mac OSX 10.8.4
  • others of us: Rails 3.2, Ruby 1.9, mysql2 0.3.13, MySQL 5.6.10, Mac OSX 10.8.4

Any ideas what might be causing this?

Thanks! Julie

like image 362
Julie Avatar asked Jul 23 '13 14:07

Julie


People also ask

Why MySQL is not working in Mac?

The reason behind the MySQL Workbench client not working can be many. It can be because your macOS version is not compatible with the version of the Workbench that you downloaded, or maybe because the version of Python installed on your macOS is not compatible with the version of Workbench you have downloaded.

Is MySQL compatible with Mac?

MySQL for macOS is available in a number of different forms: Native Package Installer, which uses the native macOS installer (DMG) to walk you through the installation of MySQL. For more information, see Chapter 2, Installing MySQL on macOS Using Native Packages. You can use the package installer with macOS.

Which version of MySQL should I download for Mac?

The free download for the Mac is the MySQL Community Server edition. Go to the MySQL website and download the latest version of MySQL for MacOS. Select the native package DMG archive version, not the compressed TAR version.


2 Answers

None of the answers here helped me, but finally I got MySQL 5.6 to work.

THREE options to fix MySQL 5.6:

  1. (confirmed) Edit /etc/my.cnf (create if not exists) and add:

    [mysqld] innodb_file_per_table = OFF 

and restart MySQL. Then for this to work you'll need to dump your databases into SQL file (mysqldump), then drop and re-create the databases, then load the data back.

  1. Change default ulimit value of OSX (suggested by Github user sodabrew): https://superuser.com/questions/261023/how-to-change-default-ulimit-values-in-mac-os-x-10-6

  2. Add the following option to [mysqld] section of my.cnf: table_open_cache = 250. By default it is set to 2000, which is way above OSX's default ulimit. This solution is also not recommended, because it hurts the performance of your MySQL - it forces MySQL to re-open tables often, if you have more than 250 tables: https://mariadb.com/kb/en/optimizing-table_open_cache/

Why this error is happening?

Since MySQL 5.6 innodb_file_per_table option is ON by default, which means that each table's data is stored in its own file. OSX default limit of the number of the open files is 256 per process. Normally this isn't a problem, but in my case I'm running unit tests in parallel, which creates 8 databases with 405 tables each. OSX has a limit of the number of open file handles per process. This StackOverflow answer suggests that this limit is 256, which explains my problem perfectly: before MySQL 5.6 all data from all these 8 databases was in ONE file.

Thanks to my colleague Thomas L. who found a MySQL bug report which hinted this solution!

like image 170
Alex Kovshovik Avatar answered Sep 22 '22 04:09

Alex Kovshovik


We had the same problem. This fixed it for us

project-root$ mysql.server stop project-root$ gem uninstall mysql2 project-root$ bundle install project-root$ mysql.server start 
like image 33
Cody Swann Avatar answered Sep 22 '22 04:09

Cody Swann