Use YUM to install MARIADB under LINUX (reproduced)

Version: centos7

For the official documentation of installing MariaDB under Linux, see: https://mariadb.com/kb/zh-cn/installing-mariadb-with-yum/

1. Create MariaDB.repo file

vi / etc / yum .repos.d / MariaDB.repo

Insert the following:

 

copy code
# MariaDB 10.1 CentOS repository list - created 2016-12-01 03:36 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
copy code

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

2. Run the install command to install MariaDB

 yum -y install MariaDB-server MariaDB-client

First download the installation package, and then perform automatic installation. After the installation is successful, start the MariaDB service.

systemctl start mariadb #Start service
systemctl enable mariadb #Set boot up
systemctl restart mariadb #restart
systemctl stop mariadb.service #停止MariaDB

3. Log in to the database

  Use the mysql -uroot command to log in to MariaDB. At this time, the password of the root account is empty.

4. Perform simple configuration related to MariaDB

  Configure using the mysql_secure_installation command.

  

  Enter to set the password of the root account

  

  Enter your password twice

  

  Other configurations: whether to delete anonymous users, whether to allow remote login, whether to delete the test database, and whether to reload the permission table. If yes, press Enter directly.

  

5. Configure the character set of MariaDB

  Check the content of the /etc/my.cnf file, which contains a sentence !includedir /etc/my.cnf.d to introduce the configuration files in the /etc/my.cnf.d directory into the configuration file.

  1) Use the vi server.cnf command to edit the server.cnf file and add it 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

 

  如果/etc/my.cnf.d 目录下无server.cnf文件,则直接在/etc/my.cnf文件的[mysqld]标签下添加以上内容。

  2)vi  client.cnf命令编辑/etc/my.cnf.d/client.cnf文件,在[client]标签下添加 

default-character-set=utf8

  3)用vi  mysql-clients.cnf命令编辑/etc/my.cnf.d/mysql-clients.cnf文件,在[mysql]标签下添加 

 

default-character-set=utf8

 

配置完成后 systemctl restart mariadb 重启服务。

进入到数据库查看字符设置。

show variables like "%character%";
show variables like "%collation%";

 

6.添加用户,设置权限

  创建用户命令:

create user username@localhost identified by 'password';

 

  Grant access to external network:

 

 

grant all privileges on *.* to username@'%' identified by 'password';

 

Use the newly created user to connect to the database OK!

 

 

 

Original address: https://www.cnblogs.com/lclq/p/5760966.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326012763&siteId=291194637
Recommended