本文主要記錄phpMyAdmin在Mac OS X上的配置和使用,避免朋友們走彎路,浪費不必要的時間。
1. 下載:
2. 在"設置"中打開" web share", 即可開啟Mac自帶的Apache, 也可以通過sudo apachectl restart, 重啟Apache。
3. 源碼放入 Apache的配置文件—httpd.cnf中DocumentRoot項指定的目錄中,並打開php5的module
#LoadModule php5_module libexec/apache2/libphp5.so
改為: LoadModule php5_module libexec/apache2/libphp5.so
4. 修改DocumentRoot下地phpmyadmin源碼的訪問權限。 chmod -R 755 phpMyAdmin-4.4.1/
5. 配置Apache的httpd.conf 如下:
<Directory "/Library/WebServer/Documents/phpMyAdmin-4.4.1">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Allow from all
</Directory>
6.在phpMyAdmin-4.4.1目錄下,復制config.example.inc.php 保存為:config.inc.php ,並修改其部分內容:
$cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */ /* * Servers configuration */ $i = 0; /* * First server */ $i++; /* Authentication type */ $cfg['Servers'][$i]['user'] = 'root'; //mysql username here $cfg['Servers'][$i]['password'] = 'xxxx'; //mysql password here $cfg['Servers'][$i]['auth_type'] = 'config'; /* Server parameters */ $cfg['Servers'][$i]['host'] = 'localhost'; $cfg['Servers'][$i]['connect_type'] = 'tcp'; $cfg['Servers'][$i]['compress'] = false; $cfg['Servers'][$i]['AllowNoPassword'] = false;
如果你忘記了mysql 密碼,可以通過如下方法修改:
1. sudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables -u root &
2. "sudo /Library/StartupItems/MySQLCOM/MySQLCOM start” 可跳過,原因未知
3. Then you should be able to log into MySQL as root: "/usr/local/mysql/bin/mysql -u root"
4. 修改密碼: "UPDATE mysql.user SET Password = PASSWORD( 'new-password' ) WHERE User = 'root';"
"FLUSH PRIVILEGES;"
"quit;"
5. 嘗試用新密碼登陸: "/usr/local/mysql/bin/mysql -u root -p"
7. 即將大功告成!此時,如果你通過sudo apachectl restart, 重啟Apache,並通過網絡地址訪問,可能還是會提示你出錯: mysql said: cannot connect: invalid settings.

這可能是應為phpmyadmin 默認使用/var/mysql/mysql.sock來連接mysqld.
8. 為phpmyadmin 的默認sock目錄創建一個連接到真實sock的鏈接。
8.1 sudo mkdir /var/mysql/
8.2 sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
9.最后fuck , 一個為程序員准備的產品,竟然不提示詳細的stack, 如不進行上一步,連錯誤提示都他媽草草了事,浪費勞資多少時間。
Mac下使用brew install phpmyadmin 安裝方案
localhost:~ xxx$ brew install phpmyadmin
==> Installing phpmyadmin from josegonzalez/homebrew-php
==> Downloading https://github.com/phpmyadmin/phpmyadmin/archive/RELEASE_4_4_4.t
######################################################################## 100.0%
==> Caveats
Note that this formula will NOT install mysql. It is not
required since you might want to get connected to a remote
database server.
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.4.4/share/phpmyadmin/doc/
Configuration has been copied to /usr/local/etc/phpmyadmin.config.inc.php
Don't forget to:
- change your secret blowfish
==> Installing phpmyadmin from josegonzalez/homebrew-php
==> Downloading https://github.com/phpmyadmin/phpmyadmin/archive/RELEASE_4_4_4.t
######################################################################## 100.0%
==> Caveats
Note that this formula will NOT install mysql. It is not
required since you might want to get connected to a remote
database server.
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.4.4/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 ...)
1. 修改/etc/apache2/httpd.conf , 並記得啟用php5.mod
2. 修改上述的phpmyadmin.config.inc.php中的配置
3. 為phpmyadmin 的默認sock目錄創建一個連接到真實sock的鏈接。
3.1 sudo mkdir /var/mysql/
3.2 sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
4. sudo apachectl restart
------------------------- Install phpmyadmin on Ubuntu------------------------------
1. install phpmod for apache2
2. install phpmysql for phpmyadmin to connect and manage mysql
3. download source code of phpmyadmin from http://www.phpmyadmin.net/home_page/downloads.php.
4. untar the downloaded phpadmin ,
4.1. move it to /var/www/html/
4.2 chmod -R 755 ./phpmyadmin/
5. setting connection options for phpmyadmin .
在phpMyAdmin-4.4.1目錄下,復制config.example.inc.php 保存為:config.inc.php ,並修改其部分內容:
$cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
/*
* Servers configuration
*/ $i = 0; /* * First server */ $i++; /* Authentication type */ $cfg['Servers'][$i]['user'] = 'root'; //mysql username here $cfg['Servers'][$i]['password'] = 'xxxx'; //mysql password here $cfg['Servers'][$i]['auth_type'] = 'config'; /* Server parameters */ $cfg['Servers'][$i]['host'] = 'localhost'; $cfg['Servers'][$i]['connect_type'] = 'tcp'; $cfg['Servers'][$i]['compress'] = false; $cfg['Servers'][$i]['AllowNoPassword'] = false;
6. check apache2.conf which located in /etc/apache2/
whether /var/www is granted to access
7. apache2ctl restart
參考:
1. http://stackoverflow.com/questions/13357561/error-1045-cannot-log-in-to-mysql-server-phpmyadmin
2. http://coolestguidesontheplanet.com/installing-phpmyadmin-on-mac-osx-10-7-lion/