Install mariadb under CentOS7 using Yum

Source: Internet
Author: User

The server/client installation package for MySQL is available in CentOS 6 or earlier versions, but CentOS 7 has used MariaDB instead of the default MySQL. MARIADB database management System is a branch of MySQL, mainly by the open source community in the maintenance, the use of GPL licensing MARIADB is fully compatible with MySQL, including the API and command line, so that it can easily become a substitute for MySQL.

Install MARIADB official documents under Linux see: https://mariadb.com/kb/zh-cn/installing-mariadb-with-yum/

Delete all mysql/mariadb

MySQL is no longer included in the CentOS 7 source, but instead MariaDB;

1. Using Rpm-qa | grep MariaDB searches for MariaDB existing packages:

If present, use RPM-E--nodeps mariadb-* to remove all:

[Email protected] ~]# Rpm-qa | grep mariadbmariadb-server-5.5.52-1. el7.x86_64mariadb-libs-5.5.52-1~]# rpm-e mysql-* Error: Package not installed MySQL

2. Using Rpm-qa | grep MariaDB searches for MariaDB existing packages:

If present, use yum remove MySQL mysql-server mysql-libs compat-mysql51 all deleted;

 [[email protected] ~]# yum remove MySQL mysql-server mysql-libs compat- mysql51 Loaded plugin: fastestmirror, langpacks parameter mysql has no matching parameters mysql -server No matching parameters compat< /span>-mysql51 no match is being resolved dependency --> checking transactions  ---> Package mariadb-libs.x86_64.1.5.5.52-1.EL7 will be deleted -processing dependencies libmysqlclient.so.18 () (64bit), which is packaged Perl-dbd-mysql-4.023-5.el7.x86_64 requires -- > is dealing with Dependency libmysqlclient.so.18 () (64bit), which is 2:postfix-2.10.1-6.el7.x86_64 needs -Processing Dependency libmysqlclient.so.18 () (64bit), which is required by package 1:qt-mysql-4.8.5-13.el7.x86_64 .... 
Delete:  mariadb-libs.x86_64 1:5.5.52-1. El7                                            as dependency removed:  akonadi-mysql.x86_64 0:1.9.2-4.el7     mariadb-server.x86_64 1:5.5.52-1. El7     perl-dbd-mysql.x86_64 0:4.023-5.el7    postfix.x86_64 2:2.10.1-6. El7            qt-mysql.x86_64 1:4.8.5-13. El7        ~]# rpm-qa|  ~]#

3. Start a new installation, create a Mariadb.repo file

Vi/etc/yum.repos.d/mariadb.repo

Insert the following content:

# MariaDB 10.2.4 CentOS repository list-created 2017-05-05 16:13 utc# http://downloads.mariadb.org/mariadb/repositories /[mariadb]name = Mariadbbaseurl = http://yum.mariadb.org/10.2.4/centos7-amd64gpgkey=https://yum.mariadb.org/ Rpm-gpg-key-mariadbgpgcheck=1

System and Version selection: https://downloads.mariadb.org/mariadb/repositories/#mirror =tuna

4. Run the install command to install MARIADB

[Email protected] ~]# yum-y install Mariadb-server mariadb-Client Loaded plugin: Fastestmirror, langpacksmariadb| 2.9 KB 00:00mariadb/primary_db | KB 00:09Determining fastest Mirrors*base:mirrors.btte.net*extras:mirrors.zju.edu.cn*updates:mirrors.zju.edu.cn is addressing dependencies-Checking Transactions---> Package mariadb-client.x86_64.0.10.2.4-1. El7.centos will be installed--The dependency Mariadb-common is being processed and it is mariadb-client-10.2.4-1 by the package. el7.centos.x86_64 needs---> Package mariadb-server.x86_64.0.10.2.4-1. El7.centos will be installed--The dependency galera is being processed and it is mariadb-server-10.2.4-1 by the package. el7.centos.x86_64 needs--Is processing dependency libjemalloc.so.1 () (64bit), which is mariadb-server-10.2.4-1 by the package. el7.centos.x86_64 needs-Checking Transactions---> Package mariadb-common.x86_64.0.10.2.4-1. El7.centos will be installed--The dependency mariadb-compat is being processed and it is mariadb-common-10.2.4-1 by the package. el7.centos.x86_64 needs---> Package galera.x86_64.0.25.3.19-1. Rhel7.el7.centos will be installed---> Package jemalloc.x86_64.0.3.6.0-1. EL7 will be installed-Checking Transactions---> Package mariadb-compat.x86_64.0.10.2.4-1. El7.centos will be installed-resolve dependencies to complete dependency relationships================================================================================Package schema version source size================================================================================Installing: MariaDB-client x86_64 10.2.4-1.el7.centos mariadb 48M MariaDB-server x86_64 10.2.4-1.el7.centos mariadb 113m installed for dependency: MariaDB-common x86_64 10.2.4-1.el7.centos mariadb 104k MariaDB-compat x86_64 10.2.4-1.el7.centos mariadb 2.8M Galera x86_6425.3.19-1.rhel7.el7.centos MARIADB 8.0M Jemalloc x86_643.6.0-1.EL7 MARIADB 104k Transaction Summary================================================================================installation2 Packages (+4dependent packages) ....

Download the installation package first, then install it automatically, and start the MARIADB service after the installation is successful.

Systemctl start mariadb #启动服务systemctl enable mariadb #设置开机启动systemctl restart mariadb #重新启动systemctl Stop Mariadb.servic E #停止MariaDB

5. Log in to the database

Log in to mariadb with the Mysql-uroot command, and the password for the root account is empty.

6. Make a simple configuration of mariadb and configure it with the Mysql_secure_installation command.

Mysql_secure_installation

The first is to set the password, you will be prompted to enter the password

Enter current password to root (enter for none): <– First run direct carriage return

Set Password

Set root Password? [y/n] <– whether to set the root user password, enter Y and return or direct enter
New Password: <– Set the root user's password
Re-enter new password: <– Enter the password you set again

Other configurations

Remove anonymous users? [y/n] <– Whether to delete anonymous users, enter

Disallow Root login remotely? [y/n] <– Whether root login is forbidden, enter,

Remove test database and access to it? [y/n] <– Whether to delete the test database, enter

Reload privilege tables now? [y/n] <– whether to reload the permissions table, enter

Initialize MARIADB complete, next Test login

Mysql-uroot-ppassword

Complete.

7. Configuring the MARIADB Character Set

File/etc/my.cnf

Vi/etc/my.cnf

Add under the [Mysqld] tab

init_connect= ' Set collation_connection = Utf8_unicode_ci ' init_connect= ' Set NAMES UTF8 ' Character-set-server=utf8 Collation-server=utf8_unicode_ci Skip-character-set-client-handshake

File/etc/my.cnf.d/client.cnf

Vi/etc/my.cnf.d/client.cnf

Add in [client]

Default-character-set=utf8

File/etc/my.cnf.d/mysql-clients.cnf

Vi/etc/my.cnf.d/mysql-clients.cnf

Add in [MySQL]

Default-character-set=utf8

Complete configuration, restart MARIADB

Systemctl Restart MARIADB

Then enter MARIADB to view the character set

Mysql> Show variables like "%character%", show variables like "%collation%";

Displayed as

+--------------------------+----------------------------+| variable_name | Value |+--------------------------+----------------------------+| character_set_client | UTF8 | | character_set_connection | UTF8 | | Character_set_database | UTF8 | | Character_set_filesystem | binary | | Character_set_results | UTF8 | | Character_set_server | UTF8 | | Character_set_system | UTF8 | | Character_sets_dir | /usr/share/mysql/charsets/|+--------------------------+----------------------------+8 rows in Set (0.00sec)+----------------------+-----------------+| variable_name | Value |+----------------------+-----------------+| collation_connection | Utf8_unicode_ci | | Collation_database | Utf8_unicode_ci | | Collation_server | Utf8_unicode_ci |+----------------------+-----------------+3 rows in Set (0.00 sec)

The character set configuration is complete.

8. Add users, set permissions

Create user command

mysql>create user [email protected] identified by ' password ';

Direct creation of user and authorized commands

Mysql>grant all on * * to [e-mail protected] indentified by ' password ';

Grant access to the extranet

Mysql>grant all privileges on * * to [e-mail protected] '% ' identified by ' password ';

Grant permissions and can authorize

Mysql>grant all privileges on * * to [e-mail protected] ' hostname ' identified by ' password ' with GRANT option;

Simple user and permission configuration is basically the case.

Where only partial permissions are granted to change all privileges or all to Select,insert,update,delete,create,drop,index,alter,grant,references,reload, Shutdown,process,file part of it.

Linux System Tutorial: How to check the MARIADB server version http://www.linuxidc.com/Linux/2015-08/122382.htm

Realization of Read and write separation of MariaDB proxy http://www.linuxidc.com/Linux/2014-05/101306.htm

Linux compiler installation Configuration mariadb database method http://www.linuxidc.com/Linux/2014-11/109049.htm

The CentOS system uses Yum to install the MARIADB database http://www.linuxidc.com/Linux/2014-11/109048.htm

Install mariadb and MySQL coexist http://www.linuxidc.com/Linux/2014-11/109047.htm

Install mariadb under CentOS7 using Yum

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.