phpMyAdmin在Mac OS X上的配置和使用

本文主要记录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  如下:
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Allow from all
 
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在Mac OS X上的配置和使用_第1张图片
   
这可能是应为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
 
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
   
      Require all granted
   

   
      Order allow,deny
      Allow from all
   

 

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/
 

你可能感兴趣的:(phpMyAdmin在Mac OS X上的配置和使用)