1. 程式人生 > 實用技巧 >Install mysql on Mac

Install mysql on Mac

Install mysql on Mac

這裡使用 homebrew 安裝。

安裝命令:

brew install mysql 

安裝之後的命令,留一個備份。
Pruned 1 symbolic links and 2 directories from /usr/local
==> Caveats
==> [email protected]
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /usr/local/etc/[email protected]/certs

and run
  /usr/local/opt/[email protected]/bin/c_rehash

[email protected] is keg-only, which means it was not symlinked into /usr/local,
because macOS provides LibreSSL.

If you need to have [email protected] first in your PATH run:
  echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc

For compilers to find [email protected] you may need to set:
  export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
  export CPPFLAGS="-I/usr/local/opt/[email protected]/include"

==> protobuf
Emacs Lisp files have been installed to:
  /usr/local/share/emacs/site-lisp/protobuf
==> mysql
We've installed your MySQL database without a root password. To secure it run:
    mysql_secure_installation

MySQL is configured to only allow connections from localhost by default

To connect run:
    mysql -uroot

To have launchd start mysql now and restart at login:
  brew services start mysql
Or, if you don't want/need a background service you can just run:
  mysql.server start

相關命令:

啟動:    mysql.server start
停止:    mysql.setver stop 
登入:    mysql -u root  ;  登入root使用者。
選擇一個database :  use  erwa 
檢視所有的database:  show databases 
檢視這個命令是幹什麼的:
man mysql 

插入成功截圖

TOPS:

1、更新homebrew的時候遇到了個小問題,卡了半天之後提示沒有許可權。

You should change the ownership of these directories to your user.

這裡根據他的提示輸入命令,然後提示輸入當前使用者的密碼,給 賦予許可權,然後重新執行OK。

2、登入的時候沒找到預設的初始密碼。 嘗試了一下不輸入密碼後,確實登入成功了。