Mysql 5.6 headaches on Mac OSX

前端 未结 8 1344
说谎
说谎 2020-12-12 20:25

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 upgrad

8条回答
  •  醉酒成梦
    2020-12-12 21:12

    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!

提交回复
热议问题