linux環(huán)境搭建之一:mysql

centos7以上的版本沒有安裝mysql,無法使用centos5一樣用rpm install mysql.rpm來安裝軟件


正確安裝方法:

1、從社區(qū)下載最新版安裝包

rpm?-Uvh?http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

2、查看當前可用的mysql安裝資源

yum?repolist?enabled?|?grep?"mysql.*-community.*"

如果顯示如下信息則說明有可用mysql安裝包

3、yum安裝mysql

yum?-y?install?mysql-community-server

4、安裝完成后進行查詢驗證是否安裝成功

rpm -qa|grep -i mysql

顯示信息如下則說明安裝成功

5、安裝完成后進行mysql配置

安裝完MySQL后,需要進行一些基礎(chǔ)配置工作:

#######安裝成功后,將其加入開機啟動

[root@typecodes?~]#?systemctl?enable?mysqld

#######啟動mysql服務進程

[root@typecodes?~]#?systemctlstartmysqld

#######配置mysql(設置密碼等)

[root@typecodes?~]#?mysql_secure_installation

NOTE:?RUNNINGALLPARTSOFTHIS?SCRIPTISRECOMMENDEDFORALLMySQL

SERVERSINPRODUCTION?USE!? PLEASEREADEACH?STEP?CAREFULLY!

InordertologintoMySQLtosecure?it,?we'll?need?the?current

password?for?the?root?user.? If?you've?just?installed?MySQL,and

you?haven't?set?the?root?password?yet,?the?password?will?be?blank,

so?you?should?just?press?enter?here.

Enter?current?password?for?root?(enter?for?none):

OK,?successfully?used?password,?moving?on...

Setting?the?root?password?ensures?that?nobody?can?log?into?the?MySQL

root?user?without?the?proper?authorisation.

Set?root?password??[Y/n]?y? ? ? ? ? ? ? ? ? [設置root用戶密碼]

New?password:

Re-enter?new?password:

Password?updated?successfully!

Reloading?privilege?tables..

...?Success!

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??[Y/n]?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??[Y/n]?y? ? ? ?[禁止root遠程登錄]

...?Success!

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??[Y/n]?y? ? ? ? ? [刪除test數(shù)據(jù)庫]

-?Dropping?test?database...

ERROR?1008?(HY000)?at?line?1:?Can'tdropdatabase'test';?database?doesn't?exist

...?Failed!? Not?critical,?keep?moving...

-?Removing?privileges?on?test?database...

...?Success!

Reloading?the?privilege?tables?will?ensure?that?all?changes?made?so?far

will?take?effect?immediately.

Reloadprivilege?tables?now??[Y/n]?y? ? ? ? ? ? [刷新權(quán)限]

...?Success!

Alldone!? If?you've?completed?all?of?the?above?steps,?your?MySQL

installation?should?now?be?secure.

Thanks?for?using?MySQL!

Cleaning?up...

6、配置完成后進行驗證是否可登陸

mysql -u root -p123456 ? ? 【root為用戶名,123456為配置時設置的密碼:注意-p和密碼之間不要有空格】

顯示如下則說明用戶名密碼設置可用并登陸成功

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容