完整的步骤——Steps::

如果顺利完成,肯定最好,但大我数情况下,都会出些状况:

http://minuo.me
  • sudo apachectl start
  • sudo nano /etc/apache2/httpd.conf
  • remove # before #LoadModule php7…
  • sudo apachectl restart
  • sudo nano /etc/apache2/httpd.conf
  • Add index.php in DirectoryIndex line
  • sudo apachectl restart
  • sudo nano /Library/WebServer/Documents/index.php
  • download and install Mysql: https://dev.mysql.com/downloads/
  • SAVE YOUR PASSWORD!
  • sudo mkdir /var/mysql
  • sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
  • Start mysql Server
  • cd /usr/local/mysql/bin
  • sudo ./mysql -u root -p
  • Alter user ’root’@‘localhost’ identified by ‘newpassword’;
  • Download phpmyadmin: https://www.phpmyadmin.net
  • Copy paste it into Documents folder and rename to phpMyAdmin
  • cd /Library/Webserver/Documents/
  • cd phpMyAdmin
  • sudo mkdir config
  • sudo chmod o+x config
  • open localhost/phpmyadmin
  • Under Authentication, enter mysql password
  • Download Config
  • Copy/Paste config into config folder
  • Enjoy

我在新的macbook pro上安装时遇到的状况:

1.命令行 输入mysql提示错误-bash: Export: command not found

ln -s  /usr/local/mysql/bin/mysql  /usr/bin

提示:ln: /usr/bin/mysql: Operation not permitted

sudo ln -s  /usr/local/mysql/bin/mysql  /usr/bin

提示:ln: /usr/bin/mysql: Operation not permitted

alias mysql=/usr/local/mysql/bin/mysql

$mysql -u root -p

输入密码,OK,成功。

2. mysqli.default_socket、pdo_mysql.default_socket的值(php.ini文件中)我这里没有用前面的步骤,我直接修改的。

在终端启动mysql,执行命令 STATUS;

使用UNIX socket的值,替换php.ini中2项的值

3.The server requested authentication method unknown to the client

这是由于新版本的mysql账号密码解锁机制不一致导致的

解决办法:

删除创建的用户和授权,

找到mysql配置文件并加入
 default_authentication_plugin=mysql_native_password
 变为原来的验证方式,然后从新创建用户并授权即可

mysql -uroot -p
use mysql;
 ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '你的密码';