LoginSignup
6
1

More than 3 years have passed since last update.

macOS CatalinaでApacheにMySQL的なものを入れたけど苦労した

Last updated at Posted at 2019-12-05

macOS CatalinaでApacheにMySQL的なものを入れようとしたのですがめっちゃ苦労したので、メモとして残しておきます。

やったこと

前回、Apacheを入れたときと同様、実際はここを参考にしたので書いてあることはほぼ一緒。

mariaDBを入れる

参考にしたサイトだと、MySQLの代替でmariaDBなるものを入れていた。
雑に説明すると、RHELとかCentOS、Wikipedia英語版とかでMySQLの代替として採用されているらしい。
詳しく知りたい人は自分で調べてください。

homebrewでmariaDBをインストールする。

brew install mariadb

起動する。

$ brew services start mariadb

MySQLサーバーのパスワードを変更する必要があるらしい。
以下のコマンドを入力。

$ sudo /usr/local/bin/mysql_secure_installation

参考にしたサイトに"You can just press return when prompted for the current root password."と書いてあったので、sudoしたあとにrootのパスワードを求められたときにreturnを叩く。

Enter current password for root (enter for none):
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

…いやなんかエラー出たが????
調べると、MySQLが起動していないと出るらしい。
多分mariaDBを入れる前にHomeBrewでMySQLを入れたのが良くなかったっぽそう。

というわけで一旦mariaDBもろとも削除して再インストール。

$ brew uninstall mysql
$ brew uninstall mariadb
$ brew install mariadb

…ダメそう(白目)

もうちょっと調べると、どうやらMySQLのファイルを完全に消しきれてないっぽい。

というわけで完全に抹消するべく以下のコマンドを入力。

$ brew uninstall mysql
$ brew uninstall mariadb
$ sudo rm -rf /usr/local/mysql
$ sudo rm -rf /Library/StartupItems/MYSQL
$ sudo rm -rf /Library/PreferencePanes/MySQL.prefPane
$ sudo rm -rf /Library/Receipts/mysql-.pkg
$ sudo rm -rf /usr/local/Cellar/mysql*
$ sudo rm -rf /usr/local/bin/mysql*
$ sudo rm -rf /usr/local/var/mysql*
$ sudo rm -rf /usr/local/etc/my.cnf
$ sudo rm -rf /usr/local/share/mysql*
$ sudo rm -rf /usr/local/opt/mysql*

リベンジする。

$ sudo install mariadb
$ sudo /usr/local/bin/mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

お、成功した!良かった…
あとはデータベース管理ソフト入れるなりすれば使えるはず…

あとがき

疲れた。

参考

macOS 10/15 Catalina Apache Setup: MySQL, Xdebug & More... | Official home of Grav CMS
「ERROR! The server quit without updating PID file」となり、MacOSでmysqlにアクセスできない。 - Qiita

6
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
1