리눅스 설치 MariaDB 댓글 | MariaDB를 설치하는 방법을 CentOS7 | CentOS7는 MariaDB를 설치

면책 조항 :이 문서는 블로거 원본입니다, 추적 에 의해-SA의 CC 4.0 저작권 계약, 복제, 원본 소스 링크이 문을 첨부 해주세요.
이 링크 : https://blog.csdn.net/mdykj33/article/details/102668834

MariaDB의 MySQL 데이터베이스 관리 시스템은 주로 유지 보수에 오픈 소스 커뮤니티에 의해, 지점이며, GPL을 사용하는 목적은 쉽게 MySQL을위한 대용품이 될 수 있도록 MariaDB는, API 및 명령 줄을 포함하여 MySQL은,와 완벽하게 호환됩니다 라이센스.

이 문서에서는 CentOS7.6 MariaDB 설치 프로세스를 설명합니다.

설치 명령

[root@db ~]# yum -y install mariadb*Loaded plugins: fastestmirrorLoading mirror speeds from cached hostfile * base: centos.ustc.edu.cn * epel: mirrors.njupt.edu.cn * extras: centos.ustc.edu.cn * updates: centos.ustc.edu.cnResolving Dependencies--> Running transaction check---> Package mariadb.x86_64 1:5.5.60-1.el7_5 will be installed---> Package mariadb-bench.x86_64 1:5.5.60-1.el7_5 will be installed---> Package mariadb-devel.x86_64 1:5.5.60-1.el7_5 will be installed---> Package mariadb-embedded.x86_64 1:5.5.60-1.el7_5 will be installed---> Package mariadb-embedded-devel.x86_64 1:5.5.60-1.el7_5 will be installed---> Package mariadb-libs.x86_64 1:5.5.60-1.el7_5 will be installed---> Package mariadb-server.x86_64 1:5.5.60-1.el7_5 will be installed--> Processing Dependency: perl-DBD-MySQL for package: 1:mariadb-server-5.5.60-1.el7_5.x86_64---> Package mariadb-test.x86_64 1:5.5.60-1.el7_5 will be installed--> Running transaction check---> Package perl-DBD-MySQL.x86_64 0:4.023-6.el7 will be installed--> Finished Dependency Resolution....

시작 MariaDB에서 :

[root@db ~]# systemctl enable mariadbCreated symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.

MariaDB를 시작합니다

[root@db ~]# systemctl start mariadb

MariaDB 상태보기 :

[root@db ~]# systemctl status mariadb● mariadb.service - MariaDB database server   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)   Active: active (running) since Fri 2019-09-13 22:54:44 CST; 32s ago  Process: 3280 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=0/SUCCESS)  Process: 3201 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS) Main PID: 3279 (mysqld_safe)   CGroup: /system.slice/mariadb.service           ├─3279 /bin/sh /usr/bin/mysqld_safe --basedir=/usr           └─3441 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/va...
Sep 13 22:54:42 db mariadb-prepare-db-dir[3201]: '/usr/bin/mysql_secure_installation'Sep 13 22:54:42 db mariadb-prepare-db-dir[3201]: which will also give you the option of removing the testSep 13 22:54:42 db mariadb-prepare-db-dir[3201]: databases and anonymous user created by default.  This isSep 13 22:54:42 db mariadb-prepare-db-dir[3201]: strongly recommended for production servers.Sep 13 22:54:42 db mariadb-prepare-db-dir[3201]: See the MariaDB Knowledgebase at http://mariadb.com/kb or theSep 13 22:54:42 db mariadb-prepare-db-dir[3201]: MySQL manual for more instructions.Sep 13 22:54:42 db mariadb-prepare-db-dir[3201]: Please report any problems at http://mariadb.org/jiraSep 13 22:54:42 db mysqld_safe[3279]: 190913 22:54:42 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.Sep 13 22:54:42 db mysqld_safe[3279]: 190913 22:54:42 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysqlSep 13 22:54:44 db systemd[1]: Started MariaDB database server.

데이터베이스, 데이터베이스 구성의 초기 설치 :

[root@db ~]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the currentpassword for the root user.  If you've just installed MariaDB, andyou haven't set the root password yet, the password will be blank,so you should just press enter here.
Enter current password for root (enter for none): OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDBroot user without the proper authorisation.
Set root password? [Y/n] yNew password: Re-enter new password: Password updated successfully!Reloading privilege tables.. ... Success!

By default, a MariaDB installation has an anonymous user, allowing anyoneto log into MariaDB without having to have a user account created forthem.  This is intended only for testing, and to make the installationgo a bit smoother.  You should remove them before moving into aproduction environment.
Remove anonymous users? [Y/n] y ... Success!
Normally, root should only be allowed to connect from 'localhost'.  Thisensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y ... Success!
By default, MariaDB comes with a database named 'test' that anyone canaccess.  This is also intended only for testing, and should be removedbefore moving into a production environment.
Remove test database and access to it? [Y/n] y - Dropping test database... ... Success! - Removing privileges on test database... ... Success!
Reloading the privilege tables will ensure that all changes made so farwill take effect immediately.
Reload privilege tables now? [Y/n] y ... Success!
Cleaning up...
All done!  If you've completed all of the above steps, your MariaDBinstallation should now be secure.
Thanks for using MariaDB!

데이터베이스 로그 :

[root@db ~]# mysql -uroot -pEnter password: Welcome to the MariaDB monitor.  Commands end with ; or \g.Your MariaDB connection id is 16Server version: 5.5.60-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>

(: UTF-8 권장 설정) 문자 집합을 설정합니다 :

[root@db ~]# vim /etc/my.cnf

다음과 같이 기본 읽

[mysqld]datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sock# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0# Settings user and group are ignored when systemd is used.# If you need to run mysqld under a different user or group,# customize your systemd unit file for mariadb according to the# instructions in http://fedoraproject.org/wiki/Systemd
[mysqld_safe]log-error=/var/log/mariadb/mariadb.logpid-file=/var/run/mariadb/mariadb.pid
## include all files from the config directory#!includedir /etc/my.cnf.d

내용을 수정합니다 :

[mysqld]datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sock# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0# Settings user and group are ignored when systemd is used.# If you need to run mysqld under a different user or group,# customize your systemd unit file for mariadb according to the# instructions in http://fedoraproject.org/wiki/Systemdinit_connect='SET collation_connection = utf8_unicode_ci'init_connect='SET NAMES utf8'character-set-server=utf8collation-server=utf8_unicode_ciskip-character-set-client-handshake
[mysqld_safe]log-error=/var/log/mariadb/mariadb.logpid-file=/var/run/mariadb/mariadb.pid
## include all files from the config directory#!includedir /etc/my.cnf.d

내용을 추가합니다 :

init_connect = 'SET collation_connection으로 = utf8_unicode_ci'

init_connect = 'SET 이름을 utf8'

문자 집합 서버 = UTF8

정렬 서버 = utf8_unicode_ci

스킵 문자 설정 클라이언트 핸드 셰이크

 

파일을 수정합니다 :

[root@db ~]# vim /etc/my.cnf.d/client.cnf

기본 내용 :

## These two groups are read by the client library# Use it for options that affect all clients, but not the server#

[client]
# This group is not read by mysql client library,# If you use the same .cnf file for MySQL and MariaDB,# use it for MariaDB-only client options[client-mariadb]

수정 된 내용 :

## These two groups are read by the client library# Use it for options that affect all clients, but not the server#

[client]default-character-set=utf8
# This group is not read by mysql client library,# If you use the same .cnf file for MySQL and MariaDB,# use it for MariaDB-only client options[client-mariadb]

내용을 추가합니다 :

기본 문자 집합 = UTF8

 

파일을 수정합니다 :

[root@db ~]# vim /etc/my.cnf.d/mysql-clients.cnf

기본 내용 :

## These groups are read by MariaDB command-line tools# Use it for options that affect only one utility#
[mysql]
[mysql_upgrade]
[mysqladmin]
[mysqlbinlog]
[mysqlcheck]
[mysqldump]
[mysqlimport]
[mysqlshow]
[mysqlslap]

수정 된 내용 :

## These groups are read by MariaDB command-line tools# Use it for options that affect only one utility#
[mysql]default-character-set=utf8
[mysql_upgrade]
[mysqladmin]
[mysqlbinlog]
[mysqlcheck]
[mysqldump]
[mysqlimport]
[mysqlshow]
[mysqlslap]

내용을 추가합니다 :

기본 문자 집합 = UTF8

그런 다음 사항을 적용하려면 서비스를 다시 시작합니다 :

[root@db ~]# systemctl restart mariadb

MYSQL 클라이언트 문자 집합을 보려면, 입력합니다 :

[root@db ~]# mysql -uroot -pEnter password: Welcome to the MariaDB monitor.  Commands end with ; or \g.Your MariaDB connection id is 4Server version: 5.5.60-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show variables like "%character%";+--------------------------+----------------------------+| 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)
MariaDB [(none)]> show variables like "%collation%";+----------------------+-----------------+| 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)

이미 열려있는 경우도 기본 루트 원격 로그인, 원격 로그인 설정 (3306)에 액세스 할 수 있도록 방화벽을 열 거부했다 :

[root@db ~]# firewall-cmd --permanent --zone=public --add-port=3306/tcpsuccess[root@db ~]# firewall-cmd --reloadsuccess

 MYSQL 클라이언트 권한을 수정 입력 :

[root@db ~]# mysql -uroot -pEnter password: Welcome to the MariaDB monitor.  Commands end with ; or \g.Your MariaDB connection id is 5Server version: 5.5.60-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> use mysql;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -A
Database changedMariaDB [mysql]> select user,host from user;+------+-----------+| user | host      |+------+-----------+| root | 127.0.0.1 || root | ::1       || root | localhost |+------+-----------+3 rows in set (0.00 sec)
MariaDB [mysql]> update user set host='%' where host='localhost';Query OK, 1 row affected (0.00 sec)Rows matched: 1  Changed: 1  Warnings: 0
MariaDB [mysql]> select user,host from user;+------+-----------+| user | host      |+------+-----------+| root | %         || root | 127.0.0.1 || root | ::1       |+------+-----------+3 rows in set (0.00 sec)
MariaDB [mysql]> flush privileges;Query OK, 0 rows affected (0.00 sec)

 

두 가지를 수행합니다 :

액세스 모든 호스트를 허용 %의 1. 수정 로컬 호스트.

2. 새로 고침을 소유합니다. (이것은 또한 서버를 다시 시작 변경할 수 있습니다.)

 

 

다음으로, 당신은 원격으로 액세스 할 수 있습니다 :

[user@client ~]$ mysql -hdb.xxx.com -uroot -pEnter password: Welcome to the MariaDB monitor.  Commands end with ; or \g.Your MariaDB connection id is 7Server version: 5.5.60-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> 

 아무 권한이없는 경우 다음과 같이하라는 메시지가 표시됩니다 :

[user@client ~]$ mysql -hdb.xxx.com -uroot -pEnter password: ERROR 1130 (HY000): Host '192.168.1.3' is not allowed to connect to this MariaDB server

이 시점에서, 우리 MariaDB의 기본 설치 및 구성 소개. 더 많은 경험을 ~ 더 후속 설명한다, 그래서 계속 지켜봐 주시기 바랍니다

기술 교육 캠프 자세한 내용은 대중 번호를 검색하십시오

추천

출처blog.csdn.net/mdykj33/article/details/102668834