AKKA
AKKA

Reputation: 165

Errors with MySQL 5.7 installation on Mac OS X El Capitan

I need some help here to understand installing and initializing MySQL on my local Macbook. First I have installed MySQL using the DMG file and everything looks like it worked fine. I even tried doing some basic hello-world type of activities on the database to get a feel of it.

Then next I came across this page in the documentation that explained the process of initializing the data directory. I got really puzzled, and just decided to uninstall MySQL following the instructions here and go through the whole installation process again. My goal for doing so was so that I could follow the initialization instructions as stated in the documentation before I started using the database, unlike in the first time round, where I started using it before I had initialized.

I found the process of initialization to be quite tricky and confusing. As I was at the step running the command

shell> bin/mysqld --initialize --user=mysql

the errors popped up

2016-01-17T17:28:21.145457Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-01-17T17:28:21.162124Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2016-01-17T17:28:21.162188Z 0 [ERROR] Aborting 

and then I another part of the documentation entitled Initializing the Data Directory Manually Using mysql, that accounted for this error and actually said:

If a data directory exists and is not empty (that is, it contains files or >subdirectories), the server exits after producing an error message:

[ERROR] --initialize specified but the data directory exists. Aborting. In this case, remove or rename the data directory and try again.

As of MySQL 5.7.11, an existing data directory is permitted to be nonempty >if every entry either has a name that begins with a period (.) or is named >using an --ignore-db-dir option.

So that was what I did and I could proceed with the initialization. After that I continued with starting up the server normally,

After you initialize the data directory by starting the server with -->initialize or --initialize-insecure, start the server normally (that is, >without either of those options) and assign the 'root'@'localhost' account >a new password: a sequence of steps I shall not quote here

and finished up the rest of the instructions in the docs, and then shutting down the server.

But I realized then the dedicated MySQL pane in the System Preferences of my Mac, which shows whether or not MySQL server is running or not, still showed that MySQL Server Instance was still running. It reminded me of the possibility that I perhaps I did not do enough to have removed the MySQL pane from System Preferences, and what I was seeing was a ghost from my first installation. I wanted to eliminate that, so I went through the whole process, uninstalling and the installing from DMG and initializing MySQL again. But this time, when I try running the server, I get a new error :

Kohs-MacBook-Pro:mysql Kohaugustine$ sudo bin/mysqld_safe --user=mysql &
[2] 15041
Kohs-MacBook-Pro:mysql Kohaugustine$ 160117 11:52:56 mysqld_safe Logging to '/usr/local/mysql-5.7.10-osx10.9-x86_64/data/Kohs-MacBook-Pro.local.err'.
160117 11:52:56 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql-5.7.10-osx10.9-x86_64/data
160117 11:52:58 mysqld_safe mysqld from pid file /usr/local/mysql-5.7.10-osx10.9-x86_64/data/Kohs-MacBook-Pro.local.pid ended

And right now, MySQL server just refuses to startup, no matter how many times I try. Not even when I do it using the GUI through the System Preferences, clicking on Start MySQL Server icon has literally no effect.

I don't know what to do right now, and would greatly appreciate any help on this!

All this just really puzzles me, and I also have the following questions for which any answers on will be of great help:

  1. Why was the data directory already created upon the automated installation from the DMG file? Did the DMG installation also do an initialization already? In that case, then why does the docs still tell us to initialize our installation?

  2. Is the method of uninstalling MySQL that I followed from the instructions I have posted above correct? Does this procedure of uninstallation actually remove MySQL pane from System Preferences?

Its been pretty frustrating trying to install MySQL, but perhaps this has to do with my overall inexperience with databases in general.

Thank you very much.

Upvotes: 0

Views: 3349

Answers (1)

simlee009
simlee009

Reputation: 26

MySQL could be shutting down because of a permissions issue with your data directory. I just ran into that problem yesterday. Try the following command:

sudo chown -R mysql /usr/local/mysql-5.7.10-osx10.9-x86_64/data

This will change the owner of the data directory to match the user that you're using to run the MySQL daemon. For what it's worth, on my Macbook (Yosemite, MySQL 5.5), the user is "_mysql" instead of "mysql". So you should double-check that.

As for your other questions...

  1. I believe the data directory comes as part of the MySQL package that you download. MySQL keeps information about itself in several MySQL databases. Those databases should be in the data directory when you do a fresh install.

  2. I haven't tried uninstalling MySQL yet, but the steps look like they should work. Specifically, the line about removing files from the PreferencePanes folder should remove the MySQL pane from System Preferences (following a reboot). The bits containing:

    sudo rm -rf .../my*
    

    make me a little uneasy though.

Do you have any *nix experience? I think that would help you more than familiarity with databases in this particular case, as you're going under the bright candy shell of OS X and getting into the dark, chocolaty center that is BSD Unix.

Hope this helps. Good luck!

Upvotes: 0

Related Questions