顯示具有 Mac 標籤的文章。 顯示所有文章
顯示具有 Mac 標籤的文章。 顯示所有文章

2016年4月23日 星期六

Mac XAMPP 改/重設 MySQL root password

Mac XAMPP reset MySQL root password

1. 先到 /Applications/XAMPP/xamppfiles/etc/my.cnf


[mysqld],在下面 (Find [mysqld] )

加 skip-grant-tables (insert "skip-grant-tables" below [mysqld])

2. 重啟 (Restart mysql)

sudo /Applications/XAMPP/xamppfiles/bin/mysql.server restart

3. 開 mysql (Enter mysql)

sudo /Applications/XAMPP/xamppfiles/bin/mysql


4. 重設 password (Reset password)
UPDATE mysql.user SET Password=PASSWORD('new_password') WHERE User='root'

5. Login (with new password)
sudo /Applications/XAMPP/xamppfiles/bin/mysql -u root -pnew_password -h localhost mysql

6. Reset my.cnf 
到 /Applications/XAMPP/xamppfiles/etc/my.cnf , delete "skip-grant-tables" 

7. 重啟

sudo /Applications/XAMPP/xamppfiles/bin/mysql.server restart

Mac 裝 XAMPP

XAMPP 有MAC的 .dmg 可供安裝

1. 先到 XAMPP 官方網頁 https://www.apachefriends.org/download.html,下載 .dmg (Download .dmg in the official website of XAMPP)











2. 雙點擊安裝 (double click to install)


















3. 裝完,啟動,在瀏覽器鍵入 http://localhost,見下列畫面即成功安裝


(Go to http://localhost/ to test if the installation is ok)












4. php 檔案,放在 /Applications/XAMPP/xamppfiles/htdocs,把新檔案放進,就能在瀏覽器運行
(the working directory is in /Applications/XAMPP/xamppfiles/htdocs)

5. 至於phpMyAdmin, 在瀏覽器鍵入 http://localhost/phpMyAdmin, 見下列畫面即成功進入管理數據庫頁面 (Go to http://localhost/phpMyAdmin to access phpMyAdmin)








6. 之後要啟動Apache server & MySQL 都需要到Terminal 行指令 (Command to start up XAMPP in Terminal)

開XAMPP的指令 (The command for start xampp)
sudo /Applications/XAMPP/xamppfiles/xampp start

開MySQL的指令 (The command for start mySql manually)
sudo /Applications/XAMPP/xamppfiles/bin/mysql.server start

7. phpMyAdmin 現在是沒有密碼的,而MySQL 預設的登入是,username: root, password: (沒有) [phpMyAdmin doesn't need to login by default and MySQL 's username is root and there is no password '']

8. 如需設置密碼,才能登入phpMyAdmin,需修改/Applications/XAMPP/xamppfiles/phpMyAdmin/config.inc.php
(If phpMyAdmin need to set login before access, change the file /Applications/XAMPP/xamppfiles/phpMyAdmin/config.inc.php)