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.  
  17. # The following options will be passed to all MySQL clients

  18. [client]

  19. #password = your_password

  20. port = 3306

  21. socket = /var/lib/mysql/mysql.sock

  22.  
  23. # Here follows entries for some specific programs

  24.  
  25. # The MySQL server

  26. [mysqld]

  27. user = mysql

  28. port=3306

  29. socket = /var/lib/mysql/mysql.sock

  30. skip-external-locking

  31. key_buffer = 4096M

  32. max_allowed_packet = 500M

  33. table_open_cache = 600000

  34. skip_name_resolve = ON

  35. table_definition_cache = 5400

  36. sort_buffer_size = 512K

  37. net_buffer_length = 8K

  38. net_read_timeout = 180

  39. net_write_timeout = 180

  40. read_buffer_size = 256K

  41. read_rnd_buffer_size = 512K

  42. myisam_sort_buffer_size = 800M

  43. bulk_insert_buffer_size = 800M

  44. slow_launch_time=2

  45. slow_query_log=on

  46. slow_query_log_file=/data/database/mysql/mongs-slow.log

  47. datadir = /data/database/mysql

  48. default-storage-engine=MyISAM

  49. character-set-server=utf8

  50. max_connections=65535

  51. max_connect_errors=65535

  52. tmp_table_size=7355443200

  53. max_heap_table_size=7355443200

  54. event_scheduler=ON

  55. concurrent_insert=2

  56. interactive_timeout=3600

  57. wait_timeout=3600

  58. #log_bin_trust_function_creators=on

  59. open_files_limit=700000

  60. #server-id = 1

  61. #log_bin =/data/database/mysql/log/binlog

  62. #log_bin_index=/data/database/mysql/log/binlog.index

  63. #relay_log =/data/database/mysql/log/relaylog

  64. #relay_log_index=/data/database/mysql/log/relaylog.index

  65. #relay_log_purge=0

  66. #max_relay_log_size=100M

  67. #expire_logs_days=2

  68.  
  69. # Where do all the plugins live

  70. plugin_dir = /var/lib/mysql/plugin/

  71.  
  72. # Don't listen on a TCP/IP port at all. This can be a security enhancement,

  73. # if all processes that need to connect to mysqld run on the same host.

  74. # All interaction with mysqld must be made via Unix sockets or named pipes.

  75. # Note that using this option without enabling named pipes on Windows

  76. # (via the "enable-named-pipe" option) will render mysqld useless!

  77. #

  78. #skip-networking

  79.  
  80. # Replication Master Server (default)

  81. # binary logging is required for replication

  82. # log-bin deactivated by default since XAMPP 1.4.11

  83. #log-bin=mysql-bin

  84.  
  85. # required unique id between 1 and 2^32 - 1

  86. # defaults to 1 if master-host is not set

  87. # but will not function as a master if omitted

  88. #server-id = 1

  89.  
  90. # Replication Slave (comment out master section to use this)

  91. #

  92. # To configure this host as a replication slave, you can choose between

  93. # two methods :

  94. #

  95. # 1) Use the CHANGE MASTER TO command (fully described in our manual) -

  96. # the syntax is:

  97. #

  98. # CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>,

  99. # MASTER_USER=<user>, MASTER_PASSWORD=<password> ;

  100. #

  101. # where you replace <host>, <user>, <password> by quoted strings and

  102. # <port> by the master's port number (3306 by default).

  103. #

  104. # Example:

  105. #

  106. # CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,

  107. # MASTER_USER='joe', MASTER_PASSWORD='secret';

  108. #

  109. # OR

  110. #

  111. # 2) Set the variables below. However, in case you choose this method, then

  112. # start replication for the first time (even unsuccessfully, for example

  113. # if you mistyped the password in master-password and the slave fails to

  114. # connect), the slave will create a master.info file, and any later

  115. # change in this file to the variables' values below will be ignored and

  116. # overridden by the content of the master.info file, unless you shutdown

  117. # the slave server, delete master.info and restart the slaver server.

  118. # For that reason, you may want to leave the lines below untouched

  119. # (commented) and instead use CHANGE MASTER TO (see above)

  120. #

  121. # required unique id between 2 and 2^32 - 1

  122. # (and different from the master)

  123. # defaults to 2 if master-host is set

  124. # but will not function as a slave if omitted

  125. #server-id = 2

  126. #

  127. # The replication master for this slave - required

  128. #master-host = <hostname>

  129. #

  130. # The username the slave will use for authentication when connecting

  131. # to the master - required

  132. #master-user = <username>

  133. #

  134. # The password the slave will authenticate with when connecting to

  135. # the master - required

  136. #master-password = <password>

  137. #

  138. # The port the master is listening on.

  139. # optional - defaults to 3306

  140. #master-port = <port>

  141. #

  142. # binary logging - not required for slaves, but recommended

  143. #log-bin=mysql-bin

  144.  
  145.  
  146. # Point the following paths to different dedicated disks

  147. #tmpdir = /tmp/

  148. #log-update = /path-to-dedicated-directory/hostname

  149.  
  150. # Uncomment the following if you are using BDB tables

  151. #bdb_cache_size = 4M

  152. #bdb_max_lock = 10000

  153.  
  154. # Comment the following if you are using InnoDB tables

  155. #skip-innodb

  156. innodb_data_home_dir = /var/lib/mysql

  157. innodb_data_file_path = ibdata1:10M:autoextend

  158. innodb_log_group_home_dir = /var/lib/mysql

  159. # You can set .._buffer_pool_size up to 50 - 80 %

  160. # of RAM but beware of setting memory usage too high

  161. innodb_buffer_pool_size = 1000M

  162. # Deprecated in 5.6

  163. #innodb_additional_mem_pool_size = 2M

  164. # Set .._log_file_size to 25 % of buffer pool size

  165. innodb_log_file_size = 5M

  166. innodb_log_buffer_size = 8M

  167. innodb_flush_log_at_trx_commit = 1

  168. innodb_lock_wait_timeout = 50

  169.  
  170. [mysqldump]

  171. quick

  172. max_allowed_packet = 512M

  173.  
  174. [mysql]

  175. no-auto-rehash

  176. # Remove the next comment character if you are not familiar with SQL

  177. #safe-updates

  178.  
  179. [isamchk]

  180. key_buffer = 20M

  181. sort_buffer_size = 20M

  182. read_buffer = 2M

  183. write_buffer = 2M

  184.  
  185. [myisamchk]

  186. key_buffer = 20M

  187. sort_buffer_size = 20M

  188. read_buffer = 2M

  189. write_buffer = 2M

  190.  
  191. [mysqlhotcopy]

  192. interactive-timeout

10.重启Mariadb

systemctl restart mysqld

11.如果启动失败

vim /etc/selinux/config 

改成如图所示

 

mysql -uroot -p

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值