安裝
brew tap
phpmyadmin 被包在另外的地方,原本的 homebrew 會 search 不到。
$ brew search phpmyadmin
No formula found for "phpmyadmin". Searching open pull requests...
是故要先將 josegonzalez/homebrew-php 匯入
$ brew tap homebrew/dupes
$ brew tap josegonzalez/homebrew-php
安裝 php54, mcrypt
因為系統內建的 php 是 5.3,而且 brew 預設是會自己安裝 php53, 所以先裝 php54 和 mcrypt (phpmyadmin 要用的)
$ brew install php54 php54-mcrypt
裝 phpmyadmin
$ brew install phpmyadmin
設定
改 Apache 設定 httpd.conf
改 php module
LoadModule php5_module /usr/local/Cellar/php54/5.4.15/libexec/apache2/libphp5.so
加入 phpmyadmin 的設定
Alias /phpmyadmin /usr/local/share/phpmyadmin
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
重新啟動 apache
$ sudo apachectl restart
設定 phpmyadmin
把內建的 sample 拿來改
$ cd $(brew --prefix phpmyadmin)/share/phpmyadmin/
$ cp config.sample.inc.php config.inc.php
加入 Blowfish Secret Variable,預設已經有一組,但還是用 generator 來產生比較好
$cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
要使用進階功能,必須設定 phpmyadmin 專屬的 user 和 db. 將下列 uncomment
// $cfg['Servers'][$i]['host'] = 'localhost';
// $cfg['Servers'][$i]['controluser'] = 'pma';
// $cfg['Servers'][$i]['controlpass'] = '建議改密碼';
// $cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
// $cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark';
// $cfg['Servers'][$i]['relation'] = 'pma_relation';
// $cfg['Servers'][$i]['table_info'] = 'pma_table_info';
// $cfg['Servers'][$i]['table_coords'] = 'pma_table_coords';
// $cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages';
// $cfg['Servers'][$i]['column_info'] = 'pma_column_info';
// $cfg['Servers'][$i]['history'] = 'pma_history';
// $cfg['Servers'][$i]['tracking'] = 'pma_tracking';
// $cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords';
// $cfg['Servers'][$i]['userconfig'] = 'pma_userconfig';
// $cfg['Servers'][$i]['recent'] = 'pma_recent';
建立 phpmyadmin 要用的資料庫
$ mysql -u root -p < /usr/local/share/phpmyadmin/examples/create_tables.sql
建立使用者 pma@localhost,密碼與 $cfg['Servers'][$i]['controlpass']
相同
授權使用者,用 SQL 標籤(無法批次輸入,需逐行執行)
GRANT USAGE ON mysql.* TO 'pma'@'localhost' IDENTIFIED BY '密碼要改';
GRANT SELECT (
Host, User, Select_priv, Insert_priv, Update_priv, Delete_priv,
Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv,
File_priv, Grant_priv, References_priv, Index_priv, Alter_priv,
Show_db_priv, Super_priv, Create_tmp_table_priv, Lock_tables_priv,
Execute_priv, Repl_slave_priv, Repl_client_priv
) ON mysql.user TO 'pma'@'localhost';
GRANT SELECT ON mysql.db TO 'pma'@'localhost';
GRANT SELECT ON mysql.host TO 'pma'@'localhost';
GRANT SELECT (Host, Db, User, Table_name, Table_priv, Column_priv)
ON mysql.tables_priv TO 'pma'@'localhost';
GRANT SELECT, INSERT, UPDATE, DELETE ON phpmyadmin.* TO 'pma'@'localhost';