7

I'am not able to get MySQL running after installation using Brew. I'am using OS X El Capitan Version 10.11.3 and MySQL Server version 5.7.11. When I start the server I receive:

Starting MySQL. ERROR! The server quit without updating PID file (/usr/local/var/mysql/Hedis-MacBook-Pro.local.pid).

and this what I get in my err file:

2016-03-19T20:59:45.907542Z 0 [ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable

Does any one have got this before?
Many thanks.

informatik01
  • 16,038
  • 10
  • 74
  • 104
Hedi Ayed
  • 371
  • 2
  • 3
  • 12
  • Verify the permissions on the ibdata1 file in your mysql data directory (usually /var/lib/mysql) – Arno Mar 23 '16 at 16:24
  • start with option --user=mysql – Bernd Buffen Mar 23 '16 at 16:27
  • Thanks Arno, I have solved the problem, yes It's question of permissions I don't know exactly why but when I put 777 to /var/mysql it works. I know it's not a good idea to do it like that but it works ;) so don't tell to security guys ;) – Hedi Ayed Mar 23 '16 at 16:48

2 Answers2

9

I received this same error after updating homebrew.

To fix this I had to reset the owner of the mysql data dir, it was changed back to my userid after the update.

cd /usr/local/mysql
sudo chown -R _mysql data/

Assuming your mysql home dir is in /usr/local

After this a restart of the service worked

$ sudo /usr/local/mysql/support-files/mysql.server start
Starting MySQL
. SUCCESS! 
DevChuck
  • 99
  • 1
  • 3
  • 3
    I think this is a bit outdated, the default directories used by brew seemed to have changed. I just ran into this same issue but for me the folder was /usr/local/var/mysql. There is no data folder anymore – stackPusher Mar 14 '18 at 01:37
  • worked great for me - OSX 12.2.1 - using an older, non-standard version of PHP@7.4 – nsdb Mar 21 '22 at 05:37
0

Brew now install mysql data to this folde: /usr/local/var/mysql/

I fixed the issue with the following:

cd /usr/local/var/mysql/

Make sure all files/folder under the above directory are owned by the right user and group. In my case, the user is me, za.

drwxr-x---   77 za   admin      2618 Jun 29  2016 mysql/
-rw-rw----    1 za   admin         5 Mar 13 11:03 mysqld_safe.pid
drwxr-x---   90 za   admin      3060 Jun 29  2016 performance_schema/
-rw-------    1 za   admin      1676 Jun 29  2016 private_key.pem
-rw-r--r--    1 za   admin       452 Jun 29  2016 public_key.pem
-rw-r--r--    1 za   admin      1079 Jun 29  2016 server-cert.pem
-rw-------    1 za   admin      1680 Jun 29  2016 server-key.pem
drwxr-x---  108 za   admin      3672 Jun 29  2016 sys/
-rw-r-----  1 _mysql  admin      3672 Jun 29  2016 somehostname.xyz.org.err 

The issue was that, this file (somehostname.xyz.org.err) was owned by _mysql, admin.

I deleted that one file and boom, mysql started successfully.

rm somehostname.xyz.org.err


  za$ /usr/local/Cellar/mysql/5.7.22/bin/mysql.server start
Starting MySQL
 SUCCESS! 

za$ /usr/local/Cellar/mysql/5.7.22/bin/mysql.server status
 SUCCESS! MySQL running (7625)

za$ /usr/local/Cellar/mysql/5.7.22/bin/mysql.server stop  
Shutting down MySQL
.. SUCCESS! 

In a different scenario, you may just need to alter ownership/permissions and not delete. Deleted mine because it is a file that will be re-created upon re-runing the service.

z atef
  • 7,138
  • 3
  • 55
  • 50