PerをやるためにXAMPPをインストール。
http://www.zubapita.jp/2008/05/02/mac%E3%81%A7web%E9%96%8B%E7%99%BA-1-xampp-for-mac%E3%81%AE%E7%92%B0%E5%A2%83%E8%A8%AD%E7%BD%AE/
ここを参考に。
MySQLの設定は、
[@ ~]$/Applications/XAMPP/xamppfiles/bin/mysqladmin -u root -p password '********'
すると、
Enter password:
/Applications/XAMPP/xamppfiles/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock' exists!
xamppfiles/etc/my.cnfのsocketをコメントアウトしてみたらMySQLは動いた。
ただし、これだとphpMyAdminがエラーを起こす。
Error
MySQL said:
#2002 - The server is not responding (or the local MySQL server's socket is not correctly configured)
xamppfiles/phpmyadmin/config.inc.phpを編集してみる。
http://zourbuth.com/2002-the-server-is-not-responding-or-the-local-mysql-servers-socket-is-not-correctly-configured/
$cfg['Servers'][$i]['connect_type'] = 'tcp';
にしてみたけどダメ。
そこでMySQLソケットの位置を確認する。
http://d.hatena.ne.jp/milk1000cc/20090303/1236049208
[@ ~]$mysql_config --socket
/tmp/mysql.sock
これをもとにmy.cnfとconfig.inc.phpに指定するも動かない。
phpMyAdminは保留。
次にセキュリティ設定を行う。
httpd.confを編集する。
<Directory "(hogehoge)/xamppfiles/htdocs">
...
Order deny, allow
Deny from All
Allow from localhost 127.0.0.1
</Directory>
あとcgi-binのフォルダも同じように設定
次に、
[@ etc]$/Applications/XAMPP/xamppfiles/xampp security
を実行。
You need to be root to perform this action.
[@ etc]$sudo /Applications/XAMPP/xamppfiles/xampp security
XAMPP: Quick security check...
XAMPP: Your XAMPP pages are NOT secured by a password.
XAMPP: Do you want to set a password? [ja]
XAMPP: Password:
XAMPP: Password (again):
XAMPP: Password protection active. Please use 'xampp' as user name!
XAMPP: MySQL is accessable via network.
XAMPP: Normaly [ja]
XAMPP: Turned off.
XAMPP: Stopping MySQL...ok.
XAMPP: Starting MySQL...ok.
XAMPP: MySQL has to run before I can check the security.
XAMPP: MySQL has to run before I can check the security.
XAMPP: MySQL has a root passwort set. Fine! :)
XAMPP: ProFTPD has a new FTP password. Great!
XAMPP: Do you want to change the password anyway? [nein]
XAMPP: Done.
"xampp"をユーザ名に使うのがデフォルト設定らしい。
これでlocalhostにアクセスするとBASIC認証のダイアログが出るようになる。
※XAMPP ControlからMySQL起動した時と、普通にターミナルから起動した時でデータベースが異なっている。
おそらくMAMPから起動するとまた別のデータベース群になると思われる。