Macの状態
- El Capitan 10.11.5です。
- brewはインストール済みです。
MySQLインストール
$ brew install mysql ==> Downloading https://homebrew.bintray.com/bottles/mysql-5.7.12.el_capitan.bottle.tar.gz Already downloaded: /Library/Caches/Homebrew/mysql-5.7.12.el_capitan.bottle.tar.gz ==> Pouring mysql-5.7.12.el_capitan.bottle.tar.gz ==> /usr/local/Cellar/mysql/5.7.12/bin/mysqld --initialize-insecure --user=hoge --basedir=/usr ==> Caveats We've installed your MySQL database without a root password. To secure it run: mysql_secure_installation To connect run: mysql -uroot To have launchd start mysql now and restart at login: brew services start mysql Or, if you don't want/need a background service you can just run: mysql.server start ==> Summary 🍺 /usr/local/Cellar/mysql/5.7.12: 13,281 files, 444.8M
MySQL起動
$ mysql.server start Starting MySQL . SUCCESS!
MySQL起動時のエラー
$ mysql.server start
Starting MySQL
. ERROR! The server quit without updating PID file (/usr/local/var/mysql/air.local.pid).
macを再起動したらなおった。mysqlを再インストールしてもなおらなかった。
MySQLの初期設定
rootパスワードの強度設定、新パスワード作成、アクセス制限などをする。全部yとしておく。
$ mysql_secure_installation
MySQLを使ってみる
$ mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 Server version: 5.7.12 Homebrew Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
phpMyAdminをインストール
phpMyAdminをダウンロードする
https://www.phpmyadmin.net/downloads/から、phpMyAdmin-4.6.2-all-languages.zipをダウンロードして、解凍する。
配置・設定
$ sudo cp -rp phpMyAdmin-4.6.2-all-languages /Library/WebServer/Documents/phpMyAdmin $ cd /Library/WebServer/Documents/phpMyAdmin $ sudo mv config.sample.inc.php config.inc.php
ブラウザで見てみる
追伸: phpMyAdminもbrewでインストールできた。
brewでphpMyAdminをインストール
参考:https://blog.frd.mn/install-nginx-php-fpm-mysql-and-phpmyadmin-on-os-x-mavericks-using-homebrew/
$ brew install autoconf $ echo 'PHP_AUTOCONF="'$(which autoconf)'"' >> ~/.bash_profile && . ~/.bash_profile $ brew install phpmyadmin 〜 中略 〜 Webserver configuration example (add this at the end of your /etc/apache2/httpd.conf for instance) : Alias /phpmyadmin /usr/local/share/phpmyadmin <Directory /usr/local/share/phpmyadmin/> Options Indexes FollowSymLinks MultiViews AllowOverride All <IfModule mod_authz_core.c> Require all granted </IfModule> <IfModule !mod_authz_core.c> Order allow,deny Allow from all </IfModule> </Directory> Then, open http://localhost/phpmyadmin More documentation : file:///usr/local/Cellar/phpmyadmin/4.6.1/share/phpmyadmin/doc/ Configuration has been copied to /usr/local/etc/phpmyadmin.config.inc.php Don't forget to: - change your secret blowfish - uncomment the configuration lines (pma, pmapass ...) ==> Summary 🍺 /usr/local/Cellar/phpmyadmin/4.6.1: 2,255 files, 63.1M, built in 14 seconds
Nginxの設定(例)
$ vim /usr/local/etc/nginx/nginx.conf
下記を最後に加える
server { listen 8080; server_name local.com; root /usr/local/share/phpmyadmin/; index index.php; location ~ \.php$ { include /usr/local/etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } }