I just installed MySQL v8.0.11 on my macOS High Sierra v10.13.4 from the dmg package downloaded from the MySQL website. The installer did not ask for any privileges or access settings during installation.
After installation finished, I tried running:
$ mysql -u root
I was returned the error ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
.
I then tried running the same command with sudo
but I was returned the same error.
Going through answers to similar questions, I tried running:
sudo /etc/init.d/mysql stop
It returns the error sudo: /etc/init.d/mysql: command not found
If then I go ahead and try the next step which is
sudo mysqld_safe --skip-grant-tables
I am returned the output
[2] 27806
[2] + 27806 suspended (tty output) sudo mysqld_safe --skip-grant-tables
Also, running
mysqld --skip-grant-tables
returns me the following errors:
mysqld: Can't change dir to '/usr/local/mysql-8.0.11-macos10.13-x86_64/data/' (OS errno 13 - Permission denied)
2018-04-20T14:29:23.579709Z 0 [System] [MY-010116] [Server] /usr/local/mysql-8.0.11-macos10.13-x86_64/bin/mysqld (mysqld 8.0.11) starting as process 29470
2018-04-20T14:29:23.593533Z 0 [Warning] [MY-010091] [Server] Can't create test file /usr/local/mysql-8.0.11-macos10.13-x86_64/data/Faheems-MacBook-Air.lower-test
2018-04-20T14:29:23.593582Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /usr/local/mysql-8.0.11-macos10.13-x86_64/data/ is case insensitive
2018-04-20T14:29:23.593863Z 0 [ERROR] [MY-010172] [Server] failed to set datadir to /usr/local/mysql-8.0.11-macos10.13-x86_64/data/
2018-04-20T14:29:23.593889Z 0 [ERROR] [MY-010119] [Server] Aborting
2018-04-20T14:29:23.594332Z 0 [System] [MY-010910] [Server] /usr/local/mysql-8.0.11-macos10.13-x86_64/bin/mysqld: Shutdown complete (mysqld 8.0.11) MySQL Community Server - GPL.
It still doesn't solve the original error or lets me run mysql. I have tried almost every answer out there on related questions but nothing works.
Thanks to anyone who can help!
After trying a few fixes, I started the MySQL server with
$ sudo mysql.server start
then went ahead with $ mysql_secure_installation
to set the password for the root user.
This worked for me.
Note: Homebrew asks you to first do mysql_secure_installation
before starting the MySQL server for the first time, but that resulted in the above-mentioned error.