日日操夜夜添-日日操影院-日日草夜夜操-日日干干-精品一区二区三区波多野结衣-精品一区二区三区高清免费不卡

公告:魔扣目錄網為廣大站長提供免費收錄網站服務,提交前請做好本站友鏈:【 網站目錄:http://www.ylptlb.cn 】, 免友鏈快審服務(50元/站),

點擊這里在線咨詢客服
新站提交
  • 網站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會員:747

0.環境

macOS Mojave 10.14.6

brew 安裝方式

MySQL選擇5.7版本

MacOS下brew安裝mysql5.7數據庫

 

一、安裝mysql5.7

查詢brew中mysql軟件包:

? ~ brew search mysql
MacOS下brew安裝mysql5.7數據庫

 

安裝mysql5.7版本:

? ~ brew install mysql@5.7

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

mysql@5.7 is keg-only, which means it was not symlinked into /usr/local,

because this is an alternate version of another formula.

If you need to have mysql@5.7 first in your PATH run:

echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.zshrc

For compilers to find mysql@5.7 you may need to set:

export LDFLAGS="-L/usr/local/opt/mysql@5.7/lib"

export CPPFLAGS="-I/usr/local/opt/mysql@5.7/include"

To have launchd start mysql@5.7 now and restart at login:

brew services start mysql@5.7

Or, if you don't want/need a background service you can just run:

/usr/local/opt/mysql@5.7/bin/mysql.server start

安裝過程如下:

MacOS下brew安裝mysql5.7數據庫

 

二、設置環境變量

? ~ vim .zshrc

在文件最后添加:

#mysql5.7
export PATH=/usr/local/opt/mysql@5.7/bin:$PATH

然后按esc退出insert狀態,并在最下方輸入:wq保存退出。

最后在刷新環境變量文件:

? ~ source ~/.zshrc

三、啟動mysql5.7

brew安裝的服務可以直接通過brew service start/stop來進行服務啟停,如下:

# 啟動 mysql, 并設置為開機啟動
brew services start mysql
# 關閉 mysql
brew services stop mysql
# 重啟 mysql
brew services restart mysql

但是,本次直接啟動報錯,如圖:

MacOS下brew安裝mysql5.7數據庫

 

明明之前安裝了,為什么會報錯呢?原因很簡單,服務名不正確!

首先,查看正確的服務名:

? ~ brew services list

顯示正確的服務名應該是‘mysql@5.7’,所以,正確的啟動服務命令為:

# 啟動 mysql, 并設置為開機啟動
brew services start mysql@5.7
# 關閉 mysql
brew services stop mysql@5.7
# 重啟 mysql
brew services restart mysql@5.7

如圖:

MacOS下brew安裝mysql5.7數據庫

 

四、執行`mysql_secure_installation`進行安全加固

主要涉及:

1.是否使用弱口令檢查?

2.輸入新密碼;

3.是否移除匿名用戶?

4.是否開啟遠程訪問數據庫連接權限?

5.是否刪除`test`數據庫?

6.刷新權限;

大家可以根據自己的情況進行設置。

? ~ mysql_secure_installation
Securing the MySQL server deployment.
Connecting to MySQL using a blank password.
VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?
Press y|Y for Yes, any other key for No: n
Please set the password for root here.
New password:
Re-enter new password:
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n
 ... skipping.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
 - Dropping test database...
Success.
 - Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done!

五、測試鏈接

1.使用Navicat測試鏈接:

MacOS下brew安裝mysql5.7數據庫

 

2.使用命令行:

MacOS下brew安裝mysql5.7數據庫

 

六、設置開機啟動

1.將/usr/local/opt/mysql@5.7/homebrew.mxcl.mysql@5.7.plist 文件拷貝到~/Library/LaunchAgents目錄下;

2.然后執行以下語句:

launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql@5.7.plist

注:這里的文件名以你mysql目錄下的名字,或者你自己創建時起的名字為準

附:Mac OS X的啟動原理:mac固件激活,初始化硬件,加載BootX引導器。BootX加載內核與內核擴展(kext)。內核啟動launchd進程。launchd根據 /System/Library/LaunchAgents, /System/Library/LaunchDaemons , /Library/LaunchDaemons,/Library/LaunchAgents , ~/Library/LaunchAgents里的plist配置,啟動服務守護進程。

[END]

分享到:
標簽:MacOS mysql
用戶無頭像

網友整理

注冊時間:

網站:5 個   小程序:0 個  文章:12 篇

  • 51998

    網站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會員

趕快注冊賬號,推廣您的網站吧!
最新入駐小程序

數獨大挑戰2018-06-03

數獨一種數學游戲,玩家需要根據9

答題星2018-06-03

您可以通過答題星輕松地創建試卷

全階人生考試2018-06-03

各種考試題,題庫,初中,高中,大學四六

運動步數有氧達人2018-06-03

記錄運動步數,積累氧氣值。還可偷

每日養生app2018-06-03

每日養生,天天健康

體育訓練成績評定2018-06-03

通用課目體育訓練成績評定