Linux7安装Mariadb10.x

?????

  1. 1.查看系统是否已有Mariadb包
  2. [root@localhost ~]# rpm -qa | grep mariadb
  3. mariadb-server-5.5.52-1.el7.x86_64
    mariadb-libs-5.5.52-1.el7.x86_64
    2.删除已有安装包
    rpm -e--nodeps mariadb-server-5.5.52-1.el7.x86_64
    rpm -e--nodeps mariadb-libs-5.5.52-1.el7.x86_64
    (使用yum remove mysql mysql-server mysql-libs compat-mysql51全部删除;)

3.查找下载地址
http://mirrors.aliyun.com/mariadb/yum/10.1/centos/7.3/x86_64/
4.建立安装脚本
编辑内容如下
vim /etc/yum.repos.d/MariaDB.repo


[mariadb]
name = MariaDB
baseurl = http://mirrors.aliyun.com/mariadb/yum/10.1/centos/7.3/x86_64/
gpgkey =http://mirrors.aliyun.com/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck = 1


:wq
5.开始yum安装
yum -y install MariaDB-server MariaDB-client
6.安装完成启动Mariadb


systemctl start mariadb

7.设置开机启动
systemctl enable mariadb

8.配置Mariadb
mysql_secure_installation

根据提示设置密码
以下仅作参考
Enter current password for root (enter for none):<–初次运行直接回车
设置密码
Set root password? [Y/n] <– 是否设置root用户密码,输入y并回车或直接回车
New password: <– 设置root用户的密码
Re-enter new password: <– 再输入一次你设置的密码
其他配置
Remove anonymous users? [Y/n] <– 是否删除匿名用户,回车
Disallow root login remotely? [Y/n] <–是否禁止root远程登录,回车,
Remove test database and access to it? [Y/n] <– 是否删除test数据库,回车
Reload privilege tables now? [Y/n] <– 是否重新加载权限表,回车
初始化MariaDB完成,接下来测试登录
mysql -uroot -ppassword


9.修改配置文件
vim /etc/my.cnf

  1. # Example MySQL config file for medium systems.
  2. #
  3. # This is for a system with little memory (32M - 64M) where MySQL plays
  4. # an important part, or systems up to 128M where MySQL is used together with
  5. # other programs (such as a web server)
  6. #
  7. # You can copy this file to
  8. # /etc/my.cnf to set global options,
  9. # mysql-data-dir/my.cnf to set server-specific options (in this
  10. # installation this directory is /opt/lampp/var/mysql) or
  11. # ~/.my.cnf to set user-specific options.
  12. #
  13. # In this file, you can use all long options that a program supports.
  14. # If you want to know which options a program supports, run the program
  15. # with the "--help" option.
  16. # The following options will be passed to all MySQL clients
  17. [client]
  18. #password = your_password
  19. port = 3306
  20. socket = /var/lib/mysql/mysql.sock
  21. # Here follows entries for some specific programs
  22. # The MySQL server
  23. [mysqld]
  24. user = mysql
  25. port=3306
  26. socket = /var/lib/mysql/mysql.sock
  27. skip-external-locking
  28. key_buffer = 4096M
  29. max_allowed_packet = 500M
  30. table_open_cache = 600000
  31. skip_name_resolve = ON
  32. table_definition_cache = 5400
  33. sort_buffer_size = 512K
  34. net_buffer_length = 8K
  35. net_read_timeout = 180
  36. net_write_timeout = 180
  37. read_buffer_size = 256K
  38. read_rnd_buffer_size = 512K
  39. myisam_sort_buffer_size = 800M
  40. bulk_insert_buffer_size = 800M
  41. slow_launch_time=2
  42. slow_query_log=on
  43. slow_query_log_file=/data/database/mysql/mongs-slow.log
  44. datadir = /data/database/mysql
  45. default-storage-engine=MyISAM
  46. character-set-server=utf8
  47. max_connections=65535
  48. max_connect_errors=65535
  49. tmp_table_size=7355443200
  50. max_heap_table_size=7355443200
  51. event_scheduler=ON
  52. concurrent_insert=2
  53. interactive_timeout=3600
  54. wait_timeout=3600
  55. #log_bin_trust_function_creators=on
  56. open_files_limit=700000
  57. #server-id = 1
  58. #log_bin =/data/database/mysql/log/binlog
  59. #log_bin_index=/data/database/mysql/log/binlog.index
  60. #relay_log =/data/database/mysql/log/relaylog
  61. #relay_log_index=/data/database/mysql/log/relaylog.index
  62. #relay_log_purge=0
  63. #max_relay_log_size=100M
  64. #expire_logs_days=2
  65. # Where do all the plugins live
  66. plugin_dir = /var/lib/mysql/plugin/
  67. # Don't listen on a TCP/IP port at all. This can be a security enhancement,
  68. # if all processes that need to connect to mysqld run on the same host.
  69. # All interaction with mysqld must be made via Unix sockets or named pipes.
  70. # Note that using this option without enabling named pipes on Windows
  71. # (via the "enable-named-pipe" option) will render mysqld useless!
  72. #
  73. #skip-networking
  74. # Replication Master Server (default)
  75. # binary logging is required for replication
  76. # log-bin deactivated by default since XAMPP 1.4.11
  77. #log-bin=mysql-bin
  78. # required unique id between 1 and 2^32 - 1
  79. # defaults to 1 if master-host is not set
  80. # but will not function as a master if omitted
  81. #server-id = 1
  82. # Replication Slave (comment out master section to use this)
  83. #
  84. # To configure this host as a replication slave, you can choose between
  85. # two methods :
  86. #
  87. # 1) Use the CHANGE MASTER TO command (fully described in our manual) -
  88. # the syntax is:
  89. #
  90. # CHANGE MASTER TO MASTER_HOST=, MASTER_PORT=,
  91. # MASTER_USER=, MASTER_PASSWORD= ;
  92. #
  93. # where you replace , , by quoted strings and
  94. # by the master's port number (3306 by default).
  95. #
  96. # Example:
  97. #
  98. # CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,
  99. # MASTER_USER='joe', MASTER_PASSWORD='secret';
  100. #
  101. # OR
  102. #
  103. # 2) Set the variables below. However, in case you choose this method, then
  104. # start replication for the first time (even unsuccessfully, for example
  105. # if you mistyped the password in master-password and the slave fails to
  106. # connect), the slave will create a master.info file, and any later
  107. # change in this file to the variables' values below will be ignored and
  108. # overridden by the content of the master.info file, unless you shutdown
  109. # the slave server, delete master.info and restart the slaver server.
  110. # For that reason, you may want to leave the lines below untouched
  111. # (commented) and instead use CHANGE MASTER TO (see above)
  112. #
  113. # required unique id between 2 and 2^32 - 1
  114. # (and different from the master)
  115. # defaults to 2 if master-host is set
  116. # but will not function as a slave if omitted
  117. #server-id = 2
  118. #
  119. # The replication master for this slave - required
  120. #master-host =
  121. #
  122. # The username the slave will use for authentication when connecting
  123. # to the master - required
  124. #master-user =
  125. #
  126. # The password the slave will authenticate with when connecting to
  127. # the master - required
  128. #master-password =
  129. #
  130. # The port the master is listening on.
  131. # optional - defaults to 3306
  132. #master-port =
  133. #
  134. # binary logging - not required for slaves, but recommended
  135. #log-bin=mysql-bin
  136. # Point the following paths to different dedicated disks
  137. #tmpdir = /tmp/
  138. #log-update = /path-to-dedicated-directory/hostname
  139. # Uncomment the following if you are using BDB tables
  140. #bdb_cache_size = 4M
  141. #bdb_max_lock = 10000
  142. # Comment the following if you are using InnoDB tables
  143. #skip-innodb
  144. innodb_data_home_dir = /var/lib/mysql
  145. innodb_data_file_path = ibdata1:10M:autoextend
  146. innodb_log_group_home_dir = /var/lib/mysql
  147. # You can set .._buffer_pool_size up to 50 - 80 %
  148. # of RAM but beware of setting memory usage too high
  149. innodb_buffer_pool_size = 1000M
  150. # Deprecated in 5.6
  151. #innodb_additional_mem_pool_size = 2M
  152. # Set .._log_file_size to 25 % of buffer pool size
  153. innodb_log_file_size = 5M
  154. innodb_log_buffer_size = 8M
  155. innodb_flush_log_at_trx_commit = 1
  156. innodb_lock_wait_timeout = 50
  157. [mysqldump]
  158. quick
  159. max_allowed_packet = 512M
  160. [mysql]
  161. no-auto-rehash
  162. # Remove the next comment character if you are not familiar with SQL
  163. #safe-updates
  164. [isamchk]
  165. key_buffer = 20M
  166. sort_buffer_size = 20M
  167. read_buffer = 2M
  168. write_buffer = 2M
  169. [myisamchk]
  170. key_buffer = 20M
  171. sort_buffer_size = 20M
  172. read_buffer = 2M
  173. write_buffer = 2M
  174. [mysqlhotcopy]
  175. interactive-timeout
10.重启Mariadb
systemctl restart mysqld
11.如果启动失败
Linux7安装Mariadb10.x
文章图片

vim /etc/selinux/config
改成如图所示
Linux7安装Mariadb10.x
文章图片


mysql -uroot -p
【Linux7安装Mariadb10.x】

    推荐阅读