mac lamp靠譜教程 Mac下用brew搭建PHP(LNMP/LAMP)開發環境php
[develop]html
/etc/hosts /private/etc/apache2/user/yuu.conf sudo apachectl restart
mac系統升級到sierra後,連localhost都沒法訪問了,我也是눈_눈。 80端口沒有佔用( sudo lsof -i :80),hosts文件不能有錯。 試着運行了 sudo /usr/sbin/httpd -k start,因而,真相,報了sytax error,在custom vhost配置文件裏,這個:"<<VirtualHost>"。修改後重啓,果真好了。mysql
sudo mysql.server start
/private/etc/php.ini display_error = on error_reporting = E_ALL & ~E_NOTICE
#git ignore file permissions, check : cat .git/config git confi core.filemode false git config - -list git config credential.helper store ## lookup present branch git branch -vv
max os自帶apache和php,因此直接用brew install mysql就好。git
沒想到mysql一直沒有安裝成功,首先是想用homebrew來裝。 而後沒有sock文件,沒法啓動。折騰了好久,最後brew uninstall mysql都沒法卸載: Error: No such keg: /usr/local/Cellar/msyqlsql
而後在stackoverflow找到了解決辦法(git e.g.):apache
//Give another go at force removing the brewed version of git brew uninstall --force git //Then cleanup any older versions and clear the brew cache brew cleanup --force -s git //Remove any dead symlinks brew prune //Then try reinstalling git brew install git
ERROR! MySQL manager or server PID file could not be found! QNAP安全
ps -ef | grep mysql kill -9 PID
官方的dmg也已經試過,dmg沒有卸載方法,只能刪目錄,以爲仍是迴歸brew算了。 How do you uninstall MySQL from Mac OS X?bash
sudo find / -name mysql ...rm sudo rm -rf /var/db/receipts/com.mysql.*
網上的教程以下:less
brew install mysql unset TMPDIR mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp sudo chown -R your_user /usr/local/var/mysql/
不過mysql_install_db這部要報錯,因此就沒有執行到。 按照brew提示 :socket
secure_mysql_installation,
提示 Error Can't connect to local MySQL server through socket '/tmp/mysql.sock'。除此以外還報了[ERROR] unknown variable 'default-character-set=utf8'這樣的錯,這個的話須要去 etc/my.cnf下把default-charactore-set改成default_set_server。
找了下tmp/根本沒有mysql.sock,因此直接:
sudo mysql.server start
這時候仍是報錯:ERROR! The server quit without updating PID file,終於後知後覺想到要去看日誌了,發現居然是文件夾沒有權限。
less /usr/local/var/mysql/hostname.err sudo chown -R mysql /usr/local/var/mysql sudo mysql.server start
SUCCESS! (╥﹏╥)。 接着設置密碼:
mysqladmin -u root password 'xxx'
Warning: Using a password on the command line interface can be insecure.(ㆆᴗㆆ) ,覺得又失敗來,忘了只有error級別纔不會終止腳本,因此密碼實際上是設置成功了的。
參考文章,
假設123456是舊密碼,654321是新密碼。
mysqladmin -p123456 password 654321
mysql> update mysql.user set password=PASSWORD('654321') where user='root'; Query OK, 4 rows affected (0.00 sec) Rows matched: 4 Changed: 4 Warnings: 0 mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)
注意mysql 5.7後 密碼的字段是authencation_string不是password。