简体   繁体   中英

MacOS Can't start MySQL Server

I have MacOS Sierra. I have installed MySQL Server which has been working, however, after a reboot of the Mac Book, I cannot start the MySQL Server.

在此处输入图片说明

I have tried changing the port from 3306 to 3307 in the my.cnf file.

Question

I would appreciate any help on how to start the MySQL Server, and also have it so it starts automatically on MacOS Boot up.

(I am new to Mac, so apologies if this is a basic question).

UPDATE

Looking for error logs, I can't find anything with todays (2/2/2017) timestamp.

在此处输入图片说明

Nothing in the data dir:

在此处输入图片说明

No files with "mysql" have been modified since I've tried to start the MySQL Server (2/2/2017 after 09:00).

在此处输入图片说明 在此处输入图片说明

I suggest to use Terminal commands.

Start MySQL

sudo /usr/local/mysql/support-files/mysql.server start

Stop MySQL

sudo /usr/local/mysql/support-files/mysql.server stop

Restart MySQL

sudo /usr/local/mysql/support-files/mysql.server restart

In my case, I had inadvertently transferred ownership of entire /usr/local directory to myself, which resulted in snatching-away of write permission of /usr/local/mysql-5.7.20-macos10.12-x86_64/data directory from the daemon user called " _mysql ".

Restoring the ownership fixed the issue.

After a discussion with Richard, the following solves the issue:

my.cnf:

[client]

port = 3306
socket = /tmp/mysql.sock


[mysqld]

port = 3306
socket = /tmp/mysql.sock
datadir = /usr/local/mysql-5.7.17-macos10.12-x86_64/data
tmpdir = /tmp

Essentially, although we'd added the relevant stanza's to the my.cnf file, we'd still missed the section heading. Adding the [mysqld] section allowed mysql to start.

After installing Mysql 8.0.12 on MacOS High Sierra, Mysql server would not start up. I tried several suggestions like removing mysql and reinstalling it, rebooting the computer and changing file permissions, all to no avail. I finally got it to work by removing /etc/my.cnf .

In my case, ownership of the msyql directory had somehow changed to admin:admin. I use ares suggestion to run mysqld from the terminal:

sudo /usr/local/mysql/support-files/mysql.server start

Which showed a permissions error writing to a msyql file.

I fixed with this command:

sudo chown -R _mysql:wheel /usr/local/mysql/data

from this post:

What user should own /usr/local/mysql on Mac?

In my case, First time, after installing Mysql, Mac needs a restart.

So restarting Mac, after installation, fixed the issue for me.

MacOS doesn't come with a my.cnf file. Default settings will suffice the needs for basic usage. Once we need to override them, it makes sense to have a custom configurations.

My problem was that due to an incorrect restart of my machine, a database was corrupted. According to their docs doing a forced InnoDB Recovery did the trick:

/etc/my.cnf

innodb_force_recovery = 2

This solution works for me.

在此处输入图片说明

You have to open the activity monitor up and search for mysqld service. Once selected, just click the delete button located in the up left part and you will see the memory goes down. After that, you can verify your mysql server status from System Preferences and the service is up.

With this solution you don't have to restart your machine and get to work fast.

My problem was that I installed MySQL a while ago with Homebrew (forgot I did) and then went the more manual route, so I think the two installs were fighting each other. I wiped my Mac of both with the help of this walkthrough: https://gist.github.com/vitorbritto/0555879fe4414d18569d

Note: Where it says to use subl - that's Sublime, use whatever editor you like.

I was able to get things to work with a fresh install after that.

I ran into same problem with following .err log.

MacOS: Catalina 10.15.7.

MySQL version: 5.7.19.

2021-08-19T02:17:26.6NZ mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
2021-08-19T02:17:27.303813Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-08-19T02:17:27.318280Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2021-08-19T02:17:27.335112Z 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.7.19) starting as process 2828 ...
2021-08-19T02:17:27.421394Z 0 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/mysql/data/ is case insensitive
2021-08-19T02:17:27.428986Z 0 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!

2021-08-19T02:17:27.429541Z 0 [ERROR] Aborting

2021-08-19T02:17:27.429688Z 0 [Note] Binlog end
2021-08-19T02:17:27.432786Z 0 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete

And I found adding --user=root to Ares's answer will start mysql server successfully.

sudo /usr/local/mysql/support-files/mysql.server start --user=root

Ref.: MySQL Server Command User Options

I had this same issue on Monterey. Make sure you're selecting the correct download according to your processor architecture. MySQL 的处理器架构下载

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM