1. Create mariadb.repo
vim /etc/yum.repos.d/mariadb.repo and
write the following:
# MariaDB 10.2 CentOS repository list - created 2017-07-03 06:59 UTC
# http://downloads.mariadb. org/mariadb/repositories/
1 [mariadb] 2 name = MariaDB 3 baseurl = https://mirrors.ustc.edu.cn/mariadb/yum/10.2/centos7-amd64 4 gpgkey=https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB 5 gpgcheck=1
Reference link: http://mirrors.ustc.edu.cn/help/mariadb.html The
above is the mariadb yum source of the University of Science and Technology of China. It is very fast to download. If you download directly from the official website, it is very slow, very slow, because This software plus dependency package, there are 167M!!!
2, yum install the latest version of mariadb
yum install MariaDB-server MariaDB-client
3. Error handling:
If the error "Failed to connect to 2001:da8:d800:95::110: Network is unreachable" is encountered during installation, replace mirrors.ustc.edu.cn in the source address with ipv4.mirrors. edu.cn to enforce IPv4:
sudo sed -i 's#//mirrors.ustc.edu.cn#//ipv4.mirrors.ustc.edu.cn#g' /etc/yum.repos.d/mariadb.repo
Various settings after Mariadb installation
1. Start MariaDB
After installing MariaDB, start MariaDB first. Both commands can be used.
systemctl start mariadb
or
service mariadb start
2, set the boot to start automatically
systemctl enable mariadb
or
chkconfig mariadb on
2. Next, perform simple configuration related to MariaDB
mysql_secure_installation
The first is to set a password, you will be prompted to enter the password first
Enter current password for root (enter for none):<--Enter directly for the first run
set password
Set root password? [Y/n] <– Whether to set the root user password, enter y and press Enter or press Enter directly New password: <– set the password of the root user Re-enter new password: <– re-enter the password you set
Other configuration
Remove anonymous users? [Y/n] <– Whether to delete anonymous users, press Enter Disallow root login remotely? [Y/n] <--whether root remote login is prohibited, press Enter, Remove test database and access to it? [Y/n] <– Whether to delete the test database, press Enter Reload privilege tables now? [Y/n] <– whether to reload privilege tables, press Enter
The initialization of MariaDB is completed, and then test the login
mysql -uroot -p [Enter, then enter password]
3. Configure the character set of MariaDB
Set up the client:
vim /etc/my.cnf.d/mysql-clients.cnf [mysql] default-character-set=utf8
Set up the server:
vim /etc/my.cnf.d/server.cnf [mysqld] init_connect='SET collation_connection = utf8_general_ci' init_connect='SET NAMES utf8' character-set-server=utf8 collation-server=utf8_general_ci skip-character-set-client-handshake
#Enable slow query
slow_query_log = ON slow_query_log_file = /usr/local/mysql/data/slow.log long_query_time = 1
All configuration is complete, restart mariadb
systemctl restart mariadb
Enter MariaDB to view the character set
mysql> show variables like "%character%";show variables like "%collation%";
shown as:
ariaDB [(none)]> show variables like "%character%";show variables like "%collation%"; +--------------------------+----------------------------+ | 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.00 sec) +----------------------+-----------------+ | Variable_name | Value | +----------------------+-----------------+ | collation_connection | utf8_general_ci | | collation_database | utf8_general_ci | | collation_server | utf8_general_ci | +----------------------+-----------------+ 3 rows in set (0.00 sec)
Character set configuration is complete.
4. Add users and set permissions
create user command
mysql>create user username@localhost identified by 'password';
Directly create user and authorize commands
mysql>grant all on *.* to username@localhost indentified by 'password';
Grant access to the external network, but not secondary authorization;
mysql>grant all privileges on *.* to username@'%' identified by 'password';
Grant permission and can authorize twice
mysql>grant all privileges on *.* to username@'hostname' identified by 'password' with grant option;
Simple user and permission configuration is basically the same.
Among them, only some permissions are granted. Change all privileges or all to:
select,insert,update,delete,create,drop,index,alter,grant,references,reload,shutdown,process,file
其中一部分。
Other references are as follows:
Linux System Tutorial: How to Check MariaDB Server Versionhttp:
//www.linuxidc.com/Linux/2015-08/122382.htm Implementation of MariaDB Proxy Read-Write Separationhttp ://www.linuxidc.com/Linux/2014- 05/101306.htm
The method of compiling, installing and configuring MariaDB database under Linuxhttp://www.linuxidc.com/Linux/2014-11/109049.htm
CentOS system uses yum to install 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
How to migrate MySQL 5.5 database to MariaDB 10 on Ubuntu http://www. linuxidc.com/Linux/2014-11/109471.htm
[Translation] Install MariaDB on Ubuntu 14.04 (Trusty) Server http://www.linuxidc.com/Linux/2014-12/110048htm
Detailed introduction of MariaDB: http:// www.linuxidc.com/Linux/2012-03/56857.html