• 设为首页
  • 收藏本站
  • 积分充值
  • VIP赞助
  • 手机版
  • 微博
  • 微信
    微信公众号 添加方式:
    1:搜索微信号(888888
    2:扫描左侧二维码
  • 快捷导航
    福建二哥 门户 查看主题

    centos 7下安装mysql(MariaDB)的教程

    发布者: 晋3555 | 发布时间: 2025-6-18 09:36| 查看数: 12| 评论数: 0|帖子模式

    centos7安装MariaDB教程,分享给大家
    1.centos7现状:
      新系统无法再使用yum install mysql-server来安装mysql,因为已使用mariadb代替mysql。
    2.安装mariadb:
    1. [root@localhost ~]# yum -y install mariadb*
    2. Loaded plugins: fastestmirror
    3. Loading mirror speeds from cached hostfile
    4. * base: mirrors.linode.com
    5. * extras: mirrors.linode.com
    6. * updates: mirrors.linode.com
    7. Resolving Dependencies
    8. --> Running transaction check
    9. ---> Package mariadb.x86_64 1:5.5.37-1.el7_0 will be installed
    10. ---> Package mariadb-bench.x86_64 1:5.5.37-1.el7_0 will be installed
    11. ---> Package mariadb-devel.x86_64 1:5.5.37-1.el7_0 will be installed
    12. ---> Package mariadb-embedded.x86_64 1:5.5.37-1.el7_0 will be installed
    13. ---> Package mariadb-embedded-devel.x86_64 1:5.5.37-1.el7_0 will be installed
    14. ---> Package mariadb-libs.x86_64 1:5.5.37-1.el7_0 will be installed
    15. ---> Package mariadb-server.x86_64 1:5.5.37-1.el7_0 will be installed
    16. --> Processing Dependency: perl-DBD-MySQL for package: 1:mariadb-server-5.5.37-1.el7_0.x86_64
    17. ---> Package mariadb-test.x86_64 1:5.5.37-1.el7_0 will be installed
    18. --> Running transaction check
    19. ---> Package perl-DBD-MySQL.x86_64 0:4.023-5.el7 will be installed
    20. --> Finished Dependency Resolution

    21. Dependencies Resolved

    22. ==========================================================================================================
    23. Package              Arch       Version           Repository     Size
    24. ==========================================================================================================
    25. Installing:
    26. mariadb              x86_64      1:5.5.37-1.el7_0      updates      8.9 M
    27. mariadb-bench           x86_64      1:5.5.37-1.el7_0      updates      385 k
    28. mariadb-devel           x86_64      1:5.5.37-1.el7_0      updates      744 k
    29. mariadb-embedded         x86_64      1:5.5.37-1.el7_0      updates      3.6 M
    30. mariadb-embedded-devel      x86_64      1:5.5.37-1.el7_0      updates      7.4 M
    31. mariadb-libs           x86_64      1:5.5.37-1.el7_0      updates      752 k
    32. mariadb-server          x86_64      1:5.5.37-1.el7_0      updates       11 M
    33. mariadb-test           x86_64      1:5.5.37-1.el7_0      updates      7.9 M
    34. Installing for dependencies:
    35. perl-DBD-MySQL          x86_64      4.023-5.el7         base        140 k

    36. Transaction Summary
    37. ==========================================================================================================
    38. Install 8 Packages (+1 Dependent package)

    39. Total download size: 40 M
    40. Installed size: 279 M
    41. Downloading packages:
    42. (1/9): mariadb-bench-5.5.37-1.el7_0.x86_64.rpm                   | 385 kB 00:00:00
    43. (2/9): mariadb-devel-5.5.37-1.el7_0.x86_64.rpm                   | 744 kB 00:00:00
    44. (3/9): mariadb-embedded-5.5.37-1.el7_0.x86_64.rpm                 | 3.6 MB 00:00:00
    45. (4/9): mariadb-5.5.37-1.el7_0.x86_64.rpm                      | 8.9 MB 00:00:00
    46. (5/9): mariadb-libs-5.5.37-1.el7_0.x86_64.rpm                   | 752 kB 00:00:00
    47. (6/9): mariadb-server-5.5.37-1.el7_0.x86_64.rpm                  | 11 MB 00:00:00
    48. (7/9): mariadb-embedded-devel-5.5.37-1.el7_0.x86_64.rpm              | 7.4 MB 00:00:00
    49. (8/9): mariadb-test-5.5.37-1.el7_0.x86_64.rpm                   | 7.9 MB 00:00:00
    50. (9/9): perl-DBD-MySQL-4.023-5.el7.x86_64.rpm                    | 140 kB 00:00:00
    51. ----------------------------------------------------------------------------------------------------------
    52. Total                                   36 MB/s | 40 MB 00:00:01
    53. Running transaction check
    54. Running transaction test
    55. Transaction test succeeded
    56. Running transaction
    57. Installing : 1:mariadb-libs-5.5.37-1.el7_0.x86_64                          1/9
    58. Installing : 1:mariadb-5.5.37-1.el7_0.x86_64                            2/9
    59. Installing : perl-DBD-MySQL-4.023-5.el7.x86_64                           3/9
    60. Installing : 1:mariadb-server-5.5.37-1.el7_0.x86_64                         4/9
    61. Installing : 1:mariadb-devel-5.5.37-1.el7_0.x86_64                         5/9
    62. Installing : 1:mariadb-embedded-5.5.37-1.el7_0.x86_64                        6/9
    63. Installing : 1:mariadb-embedded-devel-5.5.37-1.el7_0.x86_64                     7/9
    64. Installing : 1:mariadb-test-5.5.37-1.el7_0.x86_64                          8/9
    65. Installing : 1:mariadb-bench-5.5.37-1.el7_0.x86_64                         9/9
    66. Verifying : 1:mariadb-test-5.5.37-1.el7_0.x86_64                          1/9
    67. Verifying : 1:mariadb-embedded-devel-5.5.37-1.el7_0.x86_64                     2/9
    68. Verifying : 1:mariadb-embedded-5.5.37-1.el7_0.x86_64                        3/9
    69. Verifying : 1:mariadb-libs-5.5.37-1.el7_0.x86_64                          4/9
    70. Verifying : 1:mariadb-bench-5.5.37-1.el7_0.x86_64                         5/9
    71. Verifying : 1:mariadb-5.5.37-1.el7_0.x86_64                            6/9
    72. Verifying : 1:mariadb-server-5.5.37-1.el7_0.x86_64                         7/9
    73. Verifying : perl-DBD-MySQL-4.023-5.el7.x86_64                           8/9
    74. Verifying : 1:mariadb-devel-5.5.37-1.el7_0.x86_64                         9/9

    75. Installed:
    76. mariadb.x86_64 1:5.5.37-1.el7_0            mariadb-bench.x86_64 1:5.5.37-1.el7_0
    77. mariadb-devel.x86_64 1:5.5.37-1.el7_0         mariadb-embedded.x86_64 1:5.5.37-1.el7_0
    78. mariadb-embedded-devel.x86_64 1:5.5.37-1.el7_0     mariadb-libs.x86_64 1:5.5.37-1.el7_0
    79. mariadb-server.x86_64 1:5.5.37-1.el7_0         mariadb-test.x86_64 1:5.5.37-1.el7_0

    80. Dependency Installed:
    81. perl-DBD-MySQL.x86_64 0:4.023-5.el7

    82. Complete!
    83. [root@localhost ~]# systemctl start mariadb.service
    84. [root@localhost ~]# systemctl enable mariadb.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. Welcome to the MariaDB monitor. Commands end with ; or \g.
    89. Your MariaDB connection id is 2
    90. Server version: 5.5.37-MariaDB MariaDB Server

    91. Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.

    92. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

    93. MariaDB [(none)]> logout
    94.   -> exit
    95.   ->
    96.   -> ;
    97. ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaD           
    98. B server version for the right syntax to use near 'logout
    99. exit' at line 1
    100. MariaDB [(none)]> exit
    101. Bye
    102. [root@localhost ~]# systemctl enable mariadb.service
    103. [root@localhost ~]# mysql
    104. Welcome to the MariaDB monitor. Commands end with ; or \g.
    105. Your MariaDB connection id is 3
    106. Server version: 5.5.37-MariaDB MariaDB Server

    107. Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.

    108. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

    109. MariaDB [(none)]> show databases;
    110. +--------------------+
    111. | Database      |
    112. +--------------------+
    113. | information_schema |
    114. | mysql       |
    115. | performance_schema |
    116. | test        |
    117. +--------------------+
    118. rows in set (0.00 sec)

    119. MariaDB [(none)]> use test
    120. Database changed
    121. MariaDB [test]> show tables;
    122. Empty set (0.00 sec)

    123. MariaDB [test]> exit
    124. Bye
    125. [root@localhost ~]# mysql_secure_installation
    126. /usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found

    127. NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
    128.    SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

    129. In order to log into MariaDB to secure it, we'll need the current
    130. password for the root user. If you've just installed MariaDB, and
    131. you haven't set the root password yet, the password will be blank,
    132. so you should just press enter here.

    133. ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
    134. Enter current password for root (enter for none):
    135. OK, successfully used password, moving on...

    136. Setting the root password ensures that nobody can log into the MariaDB
    137. root user without the proper authorisation.

    138. Set root password? [Y/n] y
    139. New password:
    140. Re-enter new password:
    141. Password updated successfully!
    142. Reloading privilege tables..
    143. ... Success!


    144. By default, a MariaDB installation has an anonymous user, allowing anyone
    145. to log into MariaDB without having to have a user account created for
    146. them. This is intended only for testing, and to make the installation
    147. go a bit smoother. You should remove them before moving into a
    148. production environment.

    149. Remove anonymous users? [Y/n] y
    150. ... Success!

    151. Normally, root should only be allowed to connect from 'localhost'. This
    152. ensures that someone cannot guess at the root password from the network.

    153. Disallow root login remotely? [Y/n] y
    154. ... Success!

    155. By default, MariaDB comes with a database named 'test' that anyone can
    156. access. This is also intended only for testing, and should be removed
    157. before moving into a production environment.

    158. Remove test database and access to it? [Y/n] y
    159. - Dropping test database...
    160. ... Success!
    161. - Removing privileges on test database...
    162. ... Success!

    163. Reloading the privilege tables will ensure that all changes made so far
    164. will take effect immediately.

    165. Reload privilege tables now? [Y/n] y
    166. ... Success!

    167. Cleaning up...

    168. All done! If you've completed all of the above steps, your MariaDB
    169. installation should now be secure.

    170. Thanks for using MariaDB!
    171. [root@localhost ~]# mysql -uroot -p
    172. Enter password:
    173. Welcome to the MariaDB monitor. Commands end with ; or \g.
    174. Your MariaDB connection id is 15
    175. Server version: 5.5.37-MariaDB MariaDB Server

    176. Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.

    177. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

    178. MariaDB [(none)]> show databases;
    179. +--------------------+
    180. | Database      |
    181. +--------------------+
    182. | information_schema |
    183. | mysql       |
    184. | performance_schema |
    185. | zbphp.com     |
    186. +--------------------+
    187. rows in set (0.00 sec)

    188. MariaDB [(none)]>
    复制代码
    以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

    来源:https://www.jb51.net/article/115540.htm
    免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!

    最新评论

    QQ Archiver 手机版 小黑屋 福建二哥 ( 闽ICP备2022004717号|闽公网安备35052402000345号 )

    Powered by Discuz! X3.5 © 2001-2023

    快速回复 返回顶部 返回列表