CentOS 7 下 MariaDB 10 Yum Install安装

前端之家收集整理的这篇文章主要介绍了CentOS 7 下 MariaDB 10 Yum Install安装前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Linux系统信息

  1. [root@localhost ~]# cat /etc/redhat-release
  2. CentOS Linux release 7.3.1611 (Core)
  3. [root@localhost ~]# uname
  4. Linux
  5. [root@localhost ~]# uname -a
  6. Linux localhost.localdomain 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

获取Mariadb包源

来自官网的包源https://downloads.mariadb.org/mariadb/repositories/

  1. [root@localhost ~]# vim /etc/yum.repos.d/MariaDB.repo
  2.  
  3. [mariadb]
  4. name = MariaDB
  5. baseurl = http://yum.mariadb.org/10.2.1/centos7-amd64/
  6. gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
  7. gpgcheck=1

安装

安装之前确保机器上面没有YUM安装的MysqL、Mariadb

  1. [root@localhost ~]# rpm -qa | grep -i MysqL
  2. [root@localhost ~]# rpm -qa | grep -i mari
  3. [root@localhost ~]#
  4. yum remove $(rpm -qa | grep -i MysqL )
  5. yum remove $(rpm -qa | grep -i mari )
  6. yum install MariaDB-server MariaDB-client

启动Mariadb

  1. 查看自启动服务
  2. chkconfig --list | grep -i MysqL/mariadb
  3. 删除服务
  4. chkconfig --del MysqLd
  5.  
  6. systemctl start MysqL.service
  7. systemctl enable MysqL.service

选用合适的配置文件

MariaDB会给我们提供示例配置文件,根据机器内存进行选择,稍作修改即可使用。

  1. ls /usr/share/MysqL/my-*
  2. /usr/share/MysqL/my-huge.cnf /usr/share/MysqL/my-medium.cnf
  3. /usr/share/MysqL/my-innodb-heavy-4G.cnf /usr/share/MysqL/my-small.cnf
  4. /usr/share/MysqL/my-large.cnf
  5. 配置文件
  6. cp /usr/share/MysqL/my-huge.cnf /etc/my.cnf
  7. cp: overwrite ‘/etc/my.cnf’? y

重载配置文件

  1. systemctl reload MysqL.service

启动服务

  1. service MysqL start

设置root密码

1.使用命令MysqL_secure_installation

运行 MysqL_secure_installation 设置root用户密码、去除test数据库禁止root帐号远程访问等。推荐

  1. MysqL_secure_installation
  2.  
  3. NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
  4. SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
  5.  
  6. In order to log into MariaDB to secure it,we'll need the current
  7. password for the root user. If you've just installed MariaDB,and
  8. you haven't set the root password yet,the password will be blank,so you should just press enter here.
  9.  
  10. Enter current password for root (enter for none):
  11. OK,successfully used password,moving on...
  12.  
  13. Setting the root password ensures that nobody can log into the MariaDB
  14. root user without the proper authorisation.
  15.  
  16. Set root password? [Y/n] y
  17. New password:
  18. Re-enter new password:
  19. Password updated successfully!
  20. Reloading privilege tables..
  21. ... Success!
  22.  
  23.  
  24. By default,a MariaDB installation has an anonymous user,allowing anyone
  25. to log into MariaDB without having to have a user account created for
  26. them. This is intended only for testing,and to make the installation
  27. go a bit smoother. You should remove them before moving into a
  28. production environment.
  29.  
  30. Remove anonymous users? [Y/n] y
  31. ... Success!
  32.  
  33. Normally,root should only be allowed to connect from 'localhost'. This
  34. ensures that someone cannot guess at the root password from the network.
  35.  
  36. Disallow root login remotely? [Y/n] y
  37. ... Success!
  38.  
  39. By default,MariaDB comes with a database named 'test' that anyone can
  40. access. This is also intended only for testing,and should be removed
  41. before moving into a production environment.
  42.  
  43. Remove test database and access to it? [Y/n] y
  44. - Dropping test database...
  45. ... Success!
  46. - Removing privileges on test database...
  47. ... Success!
  48.  
  49. Reloading the privilege tables will ensure that all changes made so far
  50. will take effect immediately.
  51.  
  52. Reload privilege tables now? [Y/n] y
  53. ... Success!
  54.  
  55. Cleaning up...
  56.  
  57. All done! If you've completed all of the above steps,your MariaDB
  58. installation should now be secure.
  59.  
  60. Thanks for using MariaDB!

修改Mariadb数据套接

  1. [root@localhost ~]# vim /etc/my.cnf
  2. # The following options will be passed to all MariaDB clients
  3. [client]
  4. #password = your_password
  5. port = 3306
  6. socket = /tmp/MysqL.sock
  7.  
  8. # Here follows entries for some specific programs
  9.  
  10. # The MariaDB server
  11. [MysqLd]
  12. port = 3306
  13. socket = /tmp/MysqL.sock

猜你在找的CentOS相关文章