centos7以上的版本沒(méi)有安裝mysql蚯撩,無(wú)法使用centos5一樣用rpm install mysql.rpm來(lái)安裝軟件
正確安裝方法:
1秦效、從社區(qū)下載最新版安裝包
rpm?-Uvh?http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
2串塑、查看當(dāng)前可用的mysql安裝資源
yum?repolist?enabled?|?grep?"mysql.*-community.*"
如果顯示如下信息則說(shuō)明有可用mysql安裝包
3战转、yum安裝mysql
yum?-y?install?mysql-community-server
4躬审、安裝完成后進(jìn)行查詢(xún)驗(yàn)證是否安裝成功
rpm -qa|grep -i mysql
顯示信息如下則說(shuō)明安裝成功
5、安裝完成后進(jìn)行mysql配置
安裝完MySQL后矮男,需要進(jìn)行一些基礎(chǔ)配置工作:
#######安裝成功后移必,將其加入開(kāi)機(jī)啟動(dòng)
[root@typecodes?~]#?systemctl?enable?mysqld
#######啟動(dòng)mysql服務(wù)進(jìn)程
[root@typecodes?~]#?systemctlstartmysqld
#######配置mysql(設(shè)置密碼等)
[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? ? ? ? ? ? ? ? ? [設(shè)置root用戶(hù)密碼]
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? ? ? ? ? ? ? ? ?[刪除匿名用戶(hù)]
...?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遠(yuǎn)程登錄](méi)
...?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ù)庫(kù)]
-?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、配置完成后進(jìn)行驗(yàn)證是否可登陸
mysql -u root -p123456 ? ? 【root為用戶(hù)名,123456為配置時(shí)設(shè)置的密碼:注意-p和密碼之間不要有空格】
顯示如下則說(shuō)明用戶(hù)名密碼設(shè)置可用并登陸成功