centos 7下安装mysql(MariaDB)的教程
centos7安装MariaDB教程,分享给大家
1.centos7现状:
新系统无法再使用yuminstallmysql-server来安装mysql,因为已使用mariadb代替mysql。
2.安装mariadb:
[root@localhost~]#yum-yinstallmariadb* Loadedplugins:fastestmirror Loadingmirrorspeedsfromcachedhostfile *base:mirrors.linode.com *extras:mirrors.linode.com *updates:mirrors.linode.com ResolvingDependencies -->Runningtransactioncheck --->Packagemariadb.x86_641:5.5.37-1.el7_0willbeinstalled --->Packagemariadb-bench.x86_641:5.5.37-1.el7_0willbeinstalled --->Packagemariadb-devel.x86_641:5.5.37-1.el7_0willbeinstalled --->Packagemariadb-embedded.x86_641:5.5.37-1.el7_0willbeinstalled --->Packagemariadb-embedded-devel.x86_641:5.5.37-1.el7_0willbeinstalled --->Packagemariadb-libs.x86_641:5.5.37-1.el7_0willbeinstalled --->Packagemariadb-server.x86_641:5.5.37-1.el7_0willbeinstalled -->ProcessingDependency:perl-DBD-MySQLforpackage:1:mariadb-server-5.5.37-1.el7_0.x86_64 --->Packagemariadb-test.x86_641:5.5.37-1.el7_0willbeinstalled -->Runningtransactioncheck --->Packageperl-DBD-MySQL.x86_640:4.023-5.el7willbeinstalled -->FinishedDependencyResolution DependenciesResolved ========================================================================================================== PackageArchVersionRepositorySize ========================================================================================================== Installing: mariadbx86_641:5.5.37-1.el7_0updates8.9M mariadb-benchx86_641:5.5.37-1.el7_0updates385k mariadb-develx86_641:5.5.37-1.el7_0updates744k mariadb-embeddedx86_641:5.5.37-1.el7_0updates3.6M mariadb-embedded-develx86_641:5.5.37-1.el7_0updates7.4M mariadb-libsx86_641:5.5.37-1.el7_0updates752k mariadb-serverx86_641:5.5.37-1.el7_0updates11M mariadb-testx86_641:5.5.37-1.el7_0updates7.9M Installingfordependencies: perl-DBD-MySQLx86_644.023-5.el7base140k TransactionSummary ========================================================================================================== Install8Packages(+1Dependentpackage) Totaldownloadsize:40M Installedsize:279M Downloadingpackages: (1/9):mariadb-bench-5.5.37-1.el7_0.x86_64.rpm|385kB00:00:00 (2/9):mariadb-devel-5.5.37-1.el7_0.x86_64.rpm|744kB00:00:00 (3/9):mariadb-embedded-5.5.37-1.el7_0.x86_64.rpm|3.6MB00:00:00 (4/9):mariadb-5.5.37-1.el7_0.x86_64.rpm|8.9MB00:00:00 (5/9):mariadb-libs-5.5.37-1.el7_0.x86_64.rpm|752kB00:00:00 (6/9):mariadb-server-5.5.37-1.el7_0.x86_64.rpm|11MB00:00:00 (7/9):mariadb-embedded-devel-5.5.37-1.el7_0.x86_64.rpm|7.4MB00:00:00 (8/9):mariadb-test-5.5.37-1.el7_0.x86_64.rpm|7.9MB00:00:00 (9/9):perl-DBD-MySQL-4.023-5.el7.x86_64.rpm|140kB00:00:00 ---------------------------------------------------------------------------------------------------------- Total36MB/s|40MB00:00:01 Runningtransactioncheck Runningtransactiontest Transactiontestsucceeded Runningtransaction Installing:1:mariadb-libs-5.5.37-1.el7_0.x86_641/9 Installing:1:mariadb-5.5.37-1.el7_0.x86_642/9 Installing:perl-DBD-MySQL-4.023-5.el7.x86_643/9 Installing:1:mariadb-server-5.5.37-1.el7_0.x86_644/9 Installing:1:mariadb-devel-5.5.37-1.el7_0.x86_645/9 Installing:1:mariadb-embedded-5.5.37-1.el7_0.x86_646/9 Installing:1:mariadb-embedded-devel-5.5.37-1.el7_0.x86_647/9 Installing:1:mariadb-test-5.5.37-1.el7_0.x86_648/9 Installing:1:mariadb-bench-5.5.37-1.el7_0.x86_649/9 Verifying:1:mariadb-test-5.5.37-1.el7_0.x86_641/9 Verifying:1:mariadb-embedded-devel-5.5.37-1.el7_0.x86_642/9 Verifying:1:mariadb-embedded-5.5.37-1.el7_0.x86_643/9 Verifying:1:mariadb-libs-5.5.37-1.el7_0.x86_644/9 Verifying:1:mariadb-bench-5.5.37-1.el7_0.x86_645/9 Verifying:1:mariadb-5.5.37-1.el7_0.x86_646/9 Verifying:1:mariadb-server-5.5.37-1.el7_0.x86_647/9 Verifying:perl-DBD-MySQL-4.023-5.el7.x86_648/9 Verifying:1:mariadb-devel-5.5.37-1.el7_0.x86_649/9 Installed: mariadb.x86_641:5.5.37-1.el7_0mariadb-bench.x86_641:5.5.37-1.el7_0 mariadb-devel.x86_641:5.5.37-1.el7_0mariadb-embedded.x86_641:5.5.37-1.el7_0 mariadb-embedded-devel.x86_641:5.5.37-1.el7_0mariadb-libs.x86_641:5.5.37-1.el7_0 mariadb-server.x86_641:5.5.37-1.el7_0mariadb-test.x86_641:5.5.37-1.el7_0 DependencyInstalled: perl-DBD-MySQL.x86_640:4.023-5.el7 Complete! [root@localhost~]#systemctlstartmariadb.service [root@localhost~]#systemctlenablemariadb.service ln-s'/usr/lib/systemd/system/mariadb.service''/etc/systemd/system/multi-user.target.wants/mariadb.servi ce' [root@localhost~]#mysql WelcometotheMariaDBmonitor.Commandsendwith;or\g. YourMariaDBconnectionidis2 Serverversion:5.5.37-MariaDBMariaDBServer Copyright(c)2000,2014,Oracle,MontyProgramAbandothers. Type'help;'or'\h'forhelp.Type'\c'toclearthecurrentinputstatement. MariaDB[(none)]>logout ->exit -> ->; ERROR1064(42000):YouhaveanerrorinyourSQLsyntax;checkthemanualthatcorrespondstoyourMariaD Bserverversionfortherightsyntaxtousenear'logout exit'atline1 MariaDB[(none)]>exit Bye [root@localhost~]#systemctlenablemariadb.service [root@localhost~]#mysql WelcometotheMariaDBmonitor.Commandsendwith;or\g. YourMariaDBconnectionidis3 Serverversion:5.5.37-MariaDBMariaDBServer Copyright(c)2000,2014,Oracle,MontyProgramAbandothers. Type'help;'or'\h'forhelp.Type'\c'toclearthecurrentinputstatement. MariaDB[(none)]>showdatabases; +--------------------+ |Database| +--------------------+ |information_schema| |mysql| |performance_schema| |test| +--------------------+ rowsinset(0.00sec) MariaDB[(none)]>usetest Databasechanged MariaDB[test]>showtables; Emptyset(0.00sec) MariaDB[test]>exit Bye [root@localhost~]#mysql_secure_installation /usr/bin/mysql_secure_installation:line379:find_mysql_client:commandnotfound NOTE:RUNNINGALLPARTSOFTHISSCRIPTISRECOMMENDEDFORALLMariaDB SERVERSINPRODUCTIONUSE!PLEASEREADEACHSTEPCAREFULLY! InordertologintoMariaDBtosecureit,we'llneedthecurrent passwordfortherootuser.Ifyou'vejustinstalledMariaDB,and youhaven'tsettherootpasswordyet,thepasswordwillbeblank, soyoushouldjustpressenterhere. ERROR1045(28000):Accessdeniedforuser'root'@'localhost'(usingpassword:YES) Entercurrentpasswordforroot(enterfornone): OK,successfullyusedpassword,movingon... SettingtherootpasswordensuresthatnobodycanlogintotheMariaDB rootuserwithouttheproperauthorisation. Setrootpassword?[Y/n]y Newpassword: Re-enternewpassword: Passwordupdatedsuccessfully! Reloadingprivilegetables.. ...Success! Bydefault,aMariaDBinstallationhasananonymoususer,allowinganyone tologintoMariaDBwithouthavingtohaveauseraccountcreatedfor them.Thisisintendedonlyfortesting,andtomaketheinstallation goabitsmoother.Youshouldremovethembeforemovingintoa productionenvironment. Removeanonymoususers?[Y/n]y ...Success! Normally,rootshouldonlybeallowedtoconnectfrom'localhost'.This ensuresthatsomeonecannotguessattherootpasswordfromthenetwork. Disallowrootloginremotely?[Y/n]y ...Success! Bydefault,MariaDBcomeswithadatabasenamed'test'thatanyonecan access.Thisisalsointendedonlyfortesting,andshouldberemoved beforemovingintoaproductionenvironment. Removetestdatabaseandaccesstoit?[Y/n]y -Droppingtestdatabase... ...Success! -Removingprivilegesontestdatabase... ...Success! Reloadingtheprivilegetableswillensurethatallchangesmadesofar willtakeeffectimmediately. Reloadprivilegetablesnow?[Y/n]y ...Success! Cleaningup... Alldone!Ifyou'vecompletedalloftheabovesteps,yourMariaDB installationshouldnowbesecure. ThanksforusingMariaDB! [root@localhost~]#mysql-uroot-p Enterpassword: WelcometotheMariaDBmonitor.Commandsendwith;or\g. YourMariaDBconnectionidis15 Serverversion:5.5.37-MariaDBMariaDBServer Copyright(c)2000,2014,Oracle,MontyProgramAbandothers. Type'help;'or'\h'forhelp.Type'\c'toclearthecurrentinputstatement. MariaDB[(none)]>showdatabases; +--------------------+ |Database| +--------------------+ |information_schema| |mysql| |performance_schema| |zbphp.com| +--------------------+ rowsinset(0.00sec) MariaDB[(none)]>
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持毛票票。