40

Trying to install mysql5.7 with brew on Mac OS High Sierra

I have used the following commands:

sudo rm -rf /usr/local/var/mysql/
brew install mysql@5.7
brew postinstall mysql@5.7

Got the below errors

2019-10-05T02:59:24.136970Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-10-05T02:59:24.138997Z 0 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive
2019-10-05T02:59:24.215676Z 0 [Warning] InnoDB: New log files created, LSN=45790
2019-10-05T02:59:24.232279Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-10-05T02:59:24.286214Z 0 [ERROR] unknown variable 'mysqlx-bind-address=127.0.0.1'
2019-10-05T02:59:24.286281Z 0 [ERROR] Aborting

Because of which i couldn't able to do

mysql_secure_installation

which throws

Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
N20084753
  • 2,130
  • 2
  • 17
  • 12

3 Answers3

88

If you are able to find your my.cnf file (for me, it was in /usr/local/etc/my.cnf) you should remove the below line:

mysqlx-bind-address = 127.0.0.1
sbkrogers
  • 1,291
  • 12
  • 25
  • 4
    I had this problem as I had mysql v8 installed previously (also via homebrew). Brew says as much: `A "/etc/my.cnf" from another install may interfere with a Homebrew-built server starting up correctly.` – zbstof Feb 12 '20 at 19:52
  • 11
    I had to also remove `/usr/local/var/mysql` before re-running `brew postinstall mysql@5.7` – Gazza Jul 03 '20 at 14:12
  • Thank you this really helped! Yes even I had to remove all the data in `/usr/local/var/mysql` – Gurupratap Jan 13 '21 at 20:30
  • 7
    For me, Homebrew 3.1.9 in Mac Big Sur 's my.cnf file location is /opt/homebrew/etc/my.cnf – Ashok May 29 '21 at 19:24
  • 4
    In Hombrew version 3.4.11 the my.cnf is located at '/opt/homebrew/etc/my.cnf' of mac OS Monterey – Rahal Kanishka May 18 '22 at 01:14
6

Like @sbkrogers says, must to remove the line, but since I use Homebrew to install mysql@5.7:

  1. My file is located on /opt/homebrew/etc/my.cnf. Where remove mysqlx-bind-address = 127.0.0.1

  2. After the first aborted installation, following folders need to be deleted:

    • /opt/homebrew/Cellar/mysql@5.7
    • /opt/homebrew/var/mysql
  3. ...then try to install again. brew install mysql

  4. After the installation was success, restart terminal

jgu7man
  • 326
  • 1
  • 3
  • 10
1

For our case, it is due to mysql was installed earlier before mariadb. Therefore the my.cnf is already created. The my.cnf from mysql is missing some lines needed for mariadb.

The steps we did to fix:

# uninstall mariadb 
brew remove mariadb

# rename my.cnf to something else
# the homebrew etc directory is on /opt/homebrew/etc
# cd /opt/homebrew/etc
mv my.cnf my.cnf.default

# re-install
brew install mariadb

# restart and check the status
brew services restart mariadb && brew service info mariadb
ken
  • 13,869
  • 6
  • 42
  • 36