Correct command for installing mariadb on centos7

Source: Internet
Author: User

Correct command for installing mariadb on centos7

The centos7 System of linode is used, and mariadb is used by default when mysql is installed.

However, no matter whether you use the linode official website instructions or the basic installation method found by Baidu, the installation fails.

Always prompt this sentence:

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

Finally, google search for install mariadb on centos 7 to get the key step of installation.

Now that the installation is successful, please note the entire installation process:

[Php] view plaincopy
  1. Mysql: [root @ localhost ~] # Yum-yinstallmariadb *
  2. Loadedplugins: fastestmirror
  3. Loadingtransferspeedsfromcachedhostfile
  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 (+ 1 Dependentpackage)
  39. Totaldownloadsize: 40 M
  40. Installedsize: 279 M
  41. Downloadingpackages:
  42. (1/9): mariadb-bench-5.5.37-1.el7_0.x86_64.rpm | small kb00: 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. Bytes ----------------------------------------------------------------------------------------------------------
  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. Installation: 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' toclearthur ecurrentinputstatement.
  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' toclearthur ecurrentinputstatement.
  109. MariaDB [(none)]> showdatabases;
  110. + -------------------- +
  111. | Database |
  112. + -------------------- +
  113. | Information_schema |
  114. | Mysql |
  115. | Performance_schema |
  116. | Test |
  117. + -------------------- +
  118. 4 rowsinset (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. Inordertologtailmariadbtosecureit, 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. Settingtherootpasswordensuresthatnobodycanlog=themariadb
  137. Rootuserwithouttheproperauthorisation.
  138. Setrootpassword? [Y/n] y
  139. Newpassword:
  140. Re-enternewpassword:
  141. Passwordupdatedsuccessfully!
  142. Reloadingprivilegetables ..
  143. ... Success!
  144. Bydefault, amariadbinstallationhasanonymoususer, allowinganyone
  145. Tologtailmariadbwithouthavingtohaveauseraccountcreatedfor
  146. Them. Thisisintendedonlyfortesting, andtomaketheinstallation
  147. Goabitsmoother. youshouldremovethembeforemovingtransfera
  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. Beforemovingpaiaproductionenvironment.
  158. Removetestdatabaseandaccesstoit? [Y/n] y
  159. -Droppingtestdatabase...
  160. ... Success!
  161. -Removingprivilegesontestdatabase...
  162. ... Success!
  163. Reloadingtheprivilegetableswillensurethatallchangesmadesofar
  164. Willtakespontimmediately.
  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' toclearthur ecurrentinputstatement.
  178. MariaDB [(none)]> showdatabases;
  179. + -------------------- +
  180. | Database |
  181. + -------------------- +
  182. | Information_schema |
  183. | Mysql |
  184. | Performance_schema |
  185. | Zbphp.com |
  186. + -------------------- +
  187. 4 rowsinset (0.00sec)
  188. MariaDB [(none)]>

Article by default7 # zbphp.com

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.