centos7 安装 mariadb 的正确命令

分类:CentOS教程 阅读:99710 次

使用的是linode的centos7系统,安装mysql发现已经默认的是mariadb。

但是不管是使用linode官网说明还是百度搜索到的的根本安装方法无法安装成功。

总是提示这一句:

ERROR2002(HY000):Can'tconnecttolocalMySQLserverthroughsocket'/var/lib/mysql/mysql.sock'(2)

最后通过google 搜索 install mariadb on centos 7得到了安装的关键一步。

现在安装成功,特此备注一下整个安装过程:

  1. mysql:[root@localhost~]#yum-yinstallmariadb*
  2. Loadedplugins:fastestmirror
  3. Loadingmirrorspeedsfromcachedhostfile
  4. *base:mirrors.linode.com
  5. *extras:mirrors.linode.com
  6. *updates:mirrors.linode.com
  7. ResolvingDependencies
  8. -->Runningtransactioncheck
  9. --->Packagemariadb.x86_641:5.5.37-1.el7_0willbeinstalled
  10. --->Packagemariadb-bench.x86_641:5.5.37-1.el7_0willbeinstalled
  11. --->Packagemariadb-devel.x86_641:5.5.37-1.el7_0willbeinstalled
  12. --->Packagemariadb-embedded.x86_641:5.5.37-1.el7_0willbeinstalled
  13. --->Packagemariadb-embedded-devel.x86_641:5.5.37-1.el7_0willbeinstalled
  14. --->Packagemariadb-libs.x86_641:5.5.37-1.el7_0willbeinstalled
  15. --->Packagemariadb-server.x86_641:5.5.37-1.el7_0willbeinstalled
  16. -->ProcessingDependency:perl-DBD-MySQLforpackage:1:mariadb-server-5.5.37-1.el7_0.x86_64
  17. --->Packagemariadb-test.x86_641:5.5.37-1.el7_0willbeinstalled
  18. -->Runningtransactioncheck
  19. --->Packageperl-DBD-MySQL.x86_640:4.023-5.el7willbeinstalled
  20. -->FinishedDependencyResolution
  21. DependenciesResolved
  22. ==========================================================================================================
  23. PackageArchVersionRepositorySize
  24. ==========================================================================================================
  25. Installing:
  26. mariadbx86_641:5.5.37-1.el7_0updates8.9M
  27. mariadb-benchx86_641:5.5.37-1.el7_0updates385k
  28. mariadb-develx86_641:5.5.37-1.el7_0updates744k
  29. mariadb-embeddedx86_641:5.5.37-1.el7_0updates3.6M
  30. mariadb-embedded-develx86_641:5.5.37-1.el7_0updates7.4M
  31. mariadb-libsx86_641:5.5.37-1.el7_0updates752k
  32. mariadb-serverx86_641:5.5.37-1.el7_0updates11M
  33. mariadb-testx86_641:5.5.37-1.el7_0updates7.9M
  34. Installingfordependencies:
  35. perl-DBD-MySQLx86_644.023-5.el7base140k
  36. TransactionSummary
  37. ==========================================================================================================
  38. Install8Packages(+1Dependentpackage)
  39. Totaldownloadsize:40M
  40. Installedsize:279M
  41. Downloadingpackages:
  42. (1/9):mariadb-bench-5.5.37-1.el7_0.x86_64.rpm|385kB00:00:00
  43. (2/9):mariadb-devel-5.5.37-1.el7_0.x86_64.rpm|744kB00:00:00
  44. (3/9):mariadb-embedded-5.5.37-1.el7_0.x86_64.rpm|3.6MB00:00:00
  45. (4/9):mariadb-5.5.37-1.el7_0.x86_64.rpm|8.9MB00:00:00
  46. (5/9):mariadb-libs-5.5.37-1.el7_0.x86_64.rpm|752kB00:00:00
  47. (6/9):mariadb-server-5.5.37-1.el7_0.x86_64.rpm|11MB00:00:00
  48. (7/9):mariadb-embedded-devel-5.5.37-1.el7_0.x86_64.rpm|7.4MB00:00:00
  49. (8/9):mariadb-test-5.5.37-1.el7_0.x86_64.rpm|7.9MB00:00:00
  50. (9/9):perl-DBD-MySQL-4.023-5.el7.x86_64.rpm|140kB00:00:00
  51. ----------------------------------------------------------------------------------------------------------
  52. Total36MB/s|40MB00:00:01
  53. Runningtransactioncheck
  54. Runningtransactiontest
  55. Transactiontestsucceeded
  56. Runningtransaction
  57. Installing:1:mariadb-libs-5.5.37-1.el7_0.x86_641/9
  58. Installing:1:mariadb-5.5.37-1.el7_0.x86_642/9
  59. Installing:perl-DBD-MySQL-4.023-5.el7.x86_643/9
  60. Installing:1:mariadb-server-5.5.37-1.el7_0.x86_644/9
  61. Installing:1:mariadb-devel-5.5.37-1.el7_0.x86_645/9
  62. Installing:1:mariadb-embedded-5.5.37-1.el7_0.x86_646/9
  63. Installing:1:mariadb-embedded-devel-5.5.37-1.el7_0.x86_647/9
  64. Installing:1:mariadb-test-5.5.37-1.el7_0.x86_648/9
  65. Installing:1:mariadb-bench-5.5.37-1.el7_0.x86_649/9
  66. Verifying:1:mariadb-test-5.5.37-1.el7_0.x86_641/9
  67. Verifying:1:mariadb-embedded-devel-5.5.37-1.el7_0.x86_642/9
  68. Verifying:1:mariadb-embedded-5.5.37-1.el7_0.x86_643/9
  69. Verifying:1:mariadb-libs-5.5.37-1.el7_0.x86_644/9
  70. Verifying:1:mariadb-bench-5.5.37-1.el7_0.x86_645/9
  71. Verifying:1:mariadb-5.5.37-1.el7_0.x86_646/9
  72. Verifying:1:mariadb-server-5.5.37-1.el7_0.x86_647/9
  73. Verifying:perl-DBD-MySQL-4.023-5.el7.x86_648/9
  74. Verifying:1:mariadb-devel-5.5.37-1.el7_0.x86_649/9
  75. Installed:
  76. mariadb.x86_641:5.5.37-1.el7_0mariadb-bench.x86_641:5.5.37-1.el7_0
  77. mariadb-devel.x86_641:5.5.37-1.el7_0mariadb-embedded.x86_641:5.5.37-1.el7_0
  78. mariadb-embedded-devel.x86_641:5.5.37-1.el7_0mariadb-libs.x86_641:5.5.37-1.el7_0
  79. mariadb-server.x86_641:5.5.37-1.el7_0mariadb-test.x86_641:5.5.37-1.el7_0
  80. DependencyInstalled:
  81. perl-DBD-MySQL.x86_640:4.023-5.el7
  82. Complete!
  83. [root@localhost~]#systemctlstartmariadb.service
  84. [root@localhost~]#systemctlenablemariadb.service
  85. ln-s'/usr/lib/systemd/system/mariadb.service''/etc/systemd/system/multi-user.target.wants/mariadb.servi
  86. ce'
  87. [root@localhost~]#mysql
  88. WelcometotheMariaDBmonitor.Commandsendwith;or\g.
  89. YourMariaDBconnectionidis2
  90. Serverversion:5.5.37-MariaDBMariaDBServer
  91. Copyright(c)2000,2014,Oracle,MontyProgramAbandothers.
  92. Type'help;'or'\h'forhelp.Type'\c'toclearthecurrentinputstatement.
  93. MariaDB[(none)]>logout
  94. ->exit
  95. ->
  96. ->;
  97. ERROR1064(42000):YouhaveanerrorinyourSQLsyntax;checkthemanualthatcorrespondstoyourMariaD
  98. Bserverversionfortherightsyntaxtousenear'logout
  99. exit'atline1
  100. MariaDB[(none)]>exit
  101. Bye
  102. [root@localhost~]#systemctlenablemariadb.service
  103. [root@localhost~]#mysql
  104. WelcometotheMariaDBmonitor.Commandsendwith;or\g.
  105. YourMariaDBconnectionidis3
  106. Serverversion:5.5.37-MariaDBMariaDBServer
  107. Copyright(c)2000,2014,Oracle,MontyProgramAbandothers.
  108. Type'help;'or'\h'forhelp.Type'\c'toclearthecurrentinputstatement.
  109. MariaDB[(none)]>showdatabases;
  110. +--------------------+
  111. |Database|
  112. +--------------------+
  113. |information_schema|
  114. |mysql|
  115. |performance_schema|
  116. |test|
  117. +--------------------+
  118. 4rowsinset(0.00sec)
  119. MariaDB[(none)]>usetest
  120. Databasechanged
  121. MariaDB[test]>showtables;
  122. Emptyset(0.00sec)
  123. MariaDB[test]>exit
  124. Bye
  125. [root@localhost~]#mysql_secure_installation
  126. /usr/bin/mysql_secure_installation:line379:find_mysql_client:commandnotfound
  127. NOTE:RUNNINGALLPARTSOFTHISSCRIPTISRECOMMENDEDFORALLMariaDB
  128. SERVERSINPRODUCTIONUSE!PLEASEREADEACHSTEPCAREFULLY!
  129. InordertologintoMariaDBtosecureit,we'llneedthecurrent
  130. passwordfortherootuser.Ifyou'vejustinstalledMariaDB,and
  131. youhaven'tsettherootpasswordyet,thepasswordwillbeblank,
  132. soyoushouldjustpressenterhere.
  133. ERROR1045(28000):Accessdeniedforuser'root'@'localhost'(usingpassword:YES)
  134. Entercurrentpasswordforroot(enterfornone):
  135. OK,successfullyusedpassword,movingon...
  136. SettingtherootpasswordensuresthatnobodycanlogintotheMariaDB
  137. rootuserwithouttheproperauthorisation.
  138. Setrootpassword?[Y/n]y
  139. Newpassword:
  140. Re-enternewpassword:
  141. Passwordupdatedsuccessfully!
  142. Reloadingprivilegetables..
  143. ...Success!
  144. Bydefault,aMariaDBinstallationhasananonymoususer,allowinganyone
  145. tologintoMariaDBwithouthavingtohaveauseraccountcreatedfor
  146. them.Thisisintendedonlyfortesting,andtomaketheinstallation
  147. goabitsmoother.Youshouldremovethembeforemovingintoa
  148. productionenvironment.
  149. Removeanonymoususers?[Y/n]y
  150. ...Success!
  151. Normally,rootshouldonlybeallowedtoconnectfrom'localhost'.This
  152. ensuresthatsomeonecannotguessattherootpasswordfromthenetwork.
  153. Disallowrootloginremotely?[Y/n]y
  154. ...Success!
  155. Bydefault,MariaDBcomeswithadatabasenamed'test'thatanyonecan
  156. access.Thisisalsointendedonlyfortesting,andshouldberemoved
  157. beforemovingintoaproductionenvironment.
  158. Removetestdatabaseandaccesstoit?[Y/n]y
  159. -Droppingtestdatabase...
  160. ...Success!
  161. -Removingprivilegesontestdatabase...
  162. ...Success!
  163. Reloadingtheprivilegetableswillensurethatallchangesmadesofar
  164. willtakeeffectimmediately.
  165. Reloadprivilegetablesnow?[Y/n]y
  166. ...Success!
  167. Cleaningup...
  168. Alldone!Ifyou'vecompletedalloftheabovesteps,yourMariaDB
  169. installationshouldnowbesecure.
  170. ThanksforusingMariaDB!
  171. [root@localhost~]#mysql-uroot-p
  172. Enterpassword:
  173. WelcometotheMariaDBmonitor.Commandsendwith;or\g.
  174. YourMariaDBconnectionidis15
  175. Serverversion:5.5.37-MariaDBMariaDBServer
  176. Copyright(c)2000,2014,Oracle,MontyProgramAbandothers.
  177. Type'help;'or'\h'forhelp.Type'\c'toclearthecurrentinputstatement.
  178. MariaDB[(none)]>showdatabases;
  179. +--------------------+
  180. |Database|
  181. +--------------------+
  182. |information_schema|
  183. |mysql|
  184. |performance_schema|
  185. |zbphp.com|
  186. +--------------------+
  187. 4rowsinset(0.00sec)
  188. MariaDB[(none)]>

文章 by default7#zbphp.com