下載網址:https://downloads.mysql.com/archives/community/
百度網盤下載:連結:https://pan .baidu.com/s/1nceFzJKK7_dJh2gUAtVgWw 密碼:qm5z
##安裝
雙擊下載好的dmg文件,會會彈出pkg彈框,再雙擊pkg圖標,進入安裝介面,在安裝介面上一路繼續,就安裝成功了。環境變數
第一步,在終端切換到根目錄,編輯./.bash_profile檔案➜ ~ cd ~ ➜ ~ vim ./.bash_profile第二步,進入vim編輯環境,按下i進入insert模式,輸入
export PATH=$PATH:/usr/local/mysql/bin export PATH=$PATH:/usr/local/mysql/support-files第三步,按下esc 退出insert 模式,輸入:wq 儲存設定檔
:wq第四步,在終端介面輸入以下命令,讓設定檔的修改生效,並查看環境變數是否設定成功
➜ ~ echo $PATH /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin ➜ ~ source ~/.bash_profile ➜ ~ echo $PATH /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/mysql/bin:/usr/local/mysql/support-files ➜ ~
MYSQL服務的啟動停止和狀態的查看
查看MYSQL的服務狀態➜ ~ sudo mysql.server status Password: ERROR! MySQL is not running啟動MYSQL服務
➜ ~ sudo mysql.server start Starting MySQL .Logging to '/usr/local/mysql/data/mj.local.err'. SUCCESS!停止MYSQL服務
➜ ~ sudo mysql.server stop Shutting down MySQL . SUCCESS!重啟MYSQL服務
➜ ~ sudo mysql.server restart ERROR! MySQL server PID file could not be found! Starting MySQL . SUCCESS!
啟動
➜ ~ sudo mysql.server start Starting MySQL .Logging to '/usr/local/mysql/data/mj.local.err'. SUCCESS!
第二步,啟動MYSQL服務,啟動成功後繼續輸入
➜ ~ mysql -u root -p第三步,直接回車,進入資料庫,看到以下歡迎介面
Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.6.41 MySQL Community Server (GPL) Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>備註:預設安裝成功後沒有初始密碼,所以密碼不用輸入,直接回車即可。
初始化設定
設定初始密碼,進入mysql資料庫之後執行下面的語句,設定目前root使用者的密碼為root
➜ ~ mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.6.41 MySQL Community Server (GPL) Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> set password = password('root'); Query OK, 0 rows affected (0.01 sec) mysql>
退出MYSQL的介面
mysql> exit Bye ➜ ~
配置