Mac 下 MySQL的安裝


首先這次安裝使用的是brew, brew可以自行安裝.

安裝Homebrew别惦,詳細(xì)見[Homebrew](http://brew.sh/)官網(wǎng)允趟。

brew doctor
確認(rèn)brew在正常工作屎慢。

brew update
更新包。

brew install mysql
安裝mysql

那么我們就按照brew的提示運(yùn)行 mysql_secure_installation咽块,運(yùn)行后會(huì)報(bào)錯(cuò):(第一個(gè)錯(cuò)誤双戳!)

Securing the MySQL server deployment.

Enter password for user root:
Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
原因是沒有啟動(dòng)服務(wù)

運(yùn)行 mysql.server start 然后運(yùn)行 mysql_secure_installation

在此期間如果你之前安裝過mysql 需要注意把需要?jiǎng)h除的文件刪除,此次因?yàn)闆]有刪除干凈運(yùn)行 mysql.server start 出現(xiàn)錯(cuò)誤:

wanyummydeMacBook-Air:~ wanyummy$ sudo mysql.server start
Password:
Starting MySQL
... ERROR! The server quit without updating PID file (/usr/local/var/mysql/wanyummydeMacBook-Air.local.pid)

我的解決方案:將之前出現(xiàn)錯(cuò)誤的文件刪除(出現(xiàn)這種問題的原因很多)

cd /usr/local/var/mysql 
sudo rm *.err && sudo rm *.pid 
sudo reboot
sudo mysql.server start

在此運(yùn)行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: y

There are three levels of password validation policy:

LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  file
// 這里提示選一個(gè)密碼強(qiáng)度等級(jí)
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 1
Please set the password for root here.
// 然后按照所選的密碼強(qiáng)度要求設(shè)定密碼
New password:

Re-enter new password:

Estimated strength of the password: 50
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
 ... Failed! Error: Your password does not satisfy the current policy requirements

New password:

Re-enter new password:

Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
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.
// 這里刪除默認(rèn)無密碼用戶
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.
// 禁止遠(yuǎn)程root登錄,我選的是不禁止飒货。因?yàn)槲业膍ac上的數(shù)據(jù)庫(kù)不會(huì)放到公網(wǎng)上魄衅,也不會(huì)存什么敏感數(shù)據(jù)
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : no

 ... 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.

// 這里刪除默認(rèn)自帶的test數(shù)據(jù)庫(kù)
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!

登錄(一定要記住密碼!L粮ā;纬妗!?鄱铡U芤!)

mysql -u root -p 
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末呻惕,一起剝皮案震驚了整個(gè)濱河市荆责,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌亚脆,老刑警劉巖做院,帶你破解...
    沈念sama閱讀 216,997評(píng)論 6 502
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異濒持,居然都是意外死亡键耕,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,603評(píng)論 3 392
  • 文/潘曉璐 我一進(jìn)店門柑营,熙熙樓的掌柜王于貴愁眉苦臉地迎上來屈雄,“玉大人,你說我怎么就攤上這事官套【颇蹋” “怎么了?”我有些...
    開封第一講書人閱讀 163,359評(píng)論 0 353
  • 文/不壞的土叔 我叫張陵奶赔,是天一觀的道長(zhǎng)惋嚎。 經(jīng)常有香客問我,道長(zhǎng)纺阔,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,309評(píng)論 1 292
  • 正文 為了忘掉前任修然,我火速辦了婚禮笛钝,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘愕宋。我一直安慰自己玻靡,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,346評(píng)論 6 390
  • 文/花漫 我一把揭開白布中贝。 她就那樣靜靜地躺著囤捻,像睡著了一般。 火紅的嫁衣襯著肌膚如雪邻寿。 梳的紋絲不亂的頭發(fā)上蝎土,一...
    開封第一講書人閱讀 51,258評(píng)論 1 300
  • 那天视哑,我揣著相機(jī)與錄音,去河邊找鬼誊涯。 笑死挡毅,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的暴构。 我是一名探鬼主播跪呈,決...
    沈念sama閱讀 40,122評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼,長(zhǎng)吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼取逾!你這毒婦竟也來了耗绿?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 38,970評(píng)論 0 275
  • 序言:老撾萬榮一對(duì)情侶失蹤砾隅,失蹤者是張志新(化名)和其女友劉穎误阻,沒想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體琉用,經(jīng)...
    沈念sama閱讀 45,403評(píng)論 1 313
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡堕绩,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,596評(píng)論 3 334
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了邑时。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片奴紧。...
    茶點(diǎn)故事閱讀 39,769評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖晶丘,靈堂內(nèi)的尸體忽然破棺而出黍氮,到底是詐尸還是另有隱情,我是刑警寧澤浅浮,帶...
    沈念sama閱讀 35,464評(píng)論 5 344
  • 正文 年R本政府宣布沫浆,位于F島的核電站,受9級(jí)特大地震影響滚秩,放射性物質(zhì)發(fā)生泄漏专执。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,075評(píng)論 3 327
  • 文/蒙蒙 一郁油、第九天 我趴在偏房一處隱蔽的房頂上張望本股。 院中可真熱鬧,春花似錦桐腌、人聲如沸拄显。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,705評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽躬审。三九已至,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間承边,已是汗流浹背遭殉。 一陣腳步聲響...
    開封第一講書人閱讀 32,848評(píng)論 1 269
  • 我被黑心中介騙來泰國(guó)打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留炒刁,地道東北人恩沽。 一個(gè)月前我還...
    沈念sama閱讀 47,831評(píng)論 2 370
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像翔始,于是被迫代替她去往敵國(guó)和親罗心。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,678評(píng)論 2 354

推薦閱讀更多精彩內(nèi)容