MySQL MariaDB 10.x 설치하기
페이지 정보
본문
https://www.happyjung.com/lecture/2216
2. MariaDB ( MySQL ) 버전 확인
[root@localhost ~]# mysql --version
mysql Ver 15.1 Distrib 10.1.25-MariaDB, for Linux (x86_64) using readline 5.1
3. 기존에 설치되어있는 mysql 삭제
https://www.happyjung.com/lecture/2221
4. yum 레파지토리 설정
https://downloads.mariadb.org/mariadb/repositories 에 방문하여 자신의 CentOS 배포본에 적당한 yum 설정을 찾은 뒤 /etc/yum.repos.d/ 안에 MariaDB.repo 파일을 생성하여 내용을 붙여넣기 합니다.
[root@localhost ~]# vi /etc/yum.repos.d/MariaDB.repo
# MariaDB 10.2 CentOS repository list - created 2017-08-01 17:13 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.2/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
5. MariaDB 설치
[root@localhost ~]# sudo yum install MariaDB-server MariaDB-client MariaDB-common -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.riken.jp
* epel: ftp.riken.jp
* extras: ftp.riken.jp
* ius: mirrors.tongji.edu.cn
* updates: ftp.riken.jp
Resolving Dependencies
--> Running transaction check
---> Package MariaDB-client.x86_64 0:10.2.12-1.el7.centos will be installed
---> Package MariaDB-common.x86_64 0:10.2.12-1.el7.centos will be installed
--> Processing Dependency: MariaDB-compat for package: MariaDB-common-10.2.12-1.el7.centos.x86_64
---> Package MariaDB-server.x86_64 0:10.2.12-1.el7.centos will be installed
--> Running transaction check
---> Package MariaDB-compat.x86_64 0:10.2.12-1.el7.centos will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=================================================================================================================
Package Arch Version Repository Size
=================================================================================================================
Installing:
MariaDB-client x86_64 10.2.12-1.el7.centos mariadb 48 M
MariaDB-common x86_64 10.2.12-1.el7.centos mariadb 154 k
MariaDB-server x86_64 10.2.12-1.el7.centos mariadb 110 M
Installing for dependencies:
MariaDB-compat x86_64 10.2.12-1.el7.centos mariadb 2.8 M
Transaction Summary
=================================================================================================================
Install 3 Packages (+1 Dependent package)
Total download size: 160 M
Installed size: 683 M
Downloading packages:
(1/4): MariaDB-10.2.12-centos7-x86_64-common.rpm | 154 kB 00:00:01
(2/4): MariaDB-10.2.12-centos7-x86_64-compat.rpm | 2.8 MB 00:00:04
(3/4): MariaDB-10.2.12-centos7-x86_64-client.rpm | 48 MB 00:00:14
(4/4): MariaDB-10.2.12-centos7-x86_64-server.rpm | 110 MB 00:00:26
-----------------------------------------------------------------------------------------------------------------
Total 4.8 MB/s | 160 MB 00:00:33
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : MariaDB-common-10.2.12-1.el7.centos.x86_64 1/4
Installing : MariaDB-compat-10.2.12-1.el7.centos.x86_64 2/4
Installing : MariaDB-client-10.2.12-1.el7.centos.x86_64 3/4
Installing : MariaDB-server-10.2.12-1.el7.centos.x86_64 4/4
chown: cannot access ‘/var/lib/mysql’: No such file or directory
2018-01-10 10:44:10 139650319673472 [Warning] 'THREAD_CONCURRENCY' is deprecated and will be removed in a future release.
2018-01-10 10:44:11 139650318927616 [Warning] Failed to load slave replication state from table mysql.gtid_slave_pos: 1146: Table 'mysql.gtid_slave_pos' doesn't exist
PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands:
'/usr/bin/mysqladmin' -u root password 'new-password'
'/usr/bin/mysqladmin' -u root -h localhost.localdomain password 'new-password'
Alternatively you can run:
'/usr/bin/mysql_secure_installation'
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the MariaDB Knowledgebase at http://mariadb.com/kb or the
MySQL manual for more instructions.
Please report any problems at http://mariadb.org/jira
The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/
Verifying : MariaDB-client-10.2.12-1.el7.centos.x86_64 1/4
Verifying : MariaDB-compat-10.2.12-1.el7.centos.x86_64 2/4
Verifying : MariaDB-common-10.2.12-1.el7.centos.x86_64 3/4
Verifying : MariaDB-server-10.2.12-1.el7.centos.x86_64 4/4
Installed:
MariaDB-client.x86_64 0:10.2.12-1.el7.centos MariaDB-common.x86_64 0:10.2.12-1.el7.centos
MariaDB-server.x86_64 0:10.2.12-1.el7.centos
Dependency Installed:
MariaDB-compat.x86_64 0:10.2.12-1.el7.centos
Complete!
6. MariaDB 메모리 사용량이 4GB 로 최적화되었습니다
[root@localhost ~]# cp -av /usr/share/mysql/my-innodb-heavy-4G.cnf /etc/my.cnf.d/
[root@localhost ~]# vi /etc/my.cnf.d/my-innodb-heavy-4G.cnf
#innodb_additional_mem_pool_size = 16M
7. 방화벽 열기
다음번에도 자동으로 방화벽을 열기위해 --permanent 옵션추가
[root@localhost ~]# firewall-cmd --permanent --zone=public --add-service=mysql
[root@localhost ~]# firewall-cmd --permanent --zone=public --add-port=3306/tcp
[root@localhost ~]# firewall-cmd --reload
8. 설정파일 폴더 위치는 /etc/my.cnf.d 입니다.
log 설정 https://www.happyjung.com/lecture/2479
utf8mb4 설정 https://www.happyjung.com/lecture/2356
9. MariaDB 실행
[root@localhost ~]# systemctl start mariadb
10. MariaDB 자동실행 등록
[root@localhost ~]# systemctl enable mariadb
11. MariaDB 상태 확인
[root@localhost ~]# systemctl status mariadb
● mariadb.service - MariaDB 10.2.12 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/mariadb.service.d
└─migrated-from-my.cnf-settings.conf
Active: active (running) since Wed 2018-01-10 10:55:53 JST; 23s ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Main PID: 26655 (mysqld)
Status: "Taking your SQL requests now..."
CGroup: /system.slice/mariadb.service
└─26655 /usr/sbin/mysqld
Jan 10 10:55:53 localhost.localdomain mysqld[26655]: 2018-01-10 10:55:53 140563807148160 [Note] InnoDB: 5.7...205
Jan 10 10:55:53 localhost.localdomain mysqld[26655]: 2018-01-10 10:55:53 140560371275520 [Note] InnoDB: Loa...ool
Jan 10 10:55:53 localhost.localdomain mysqld[26655]: 2018-01-10 10:55:53 140563807148160 [Note] Plugin 'FEE...ed.
Jan 10 10:55:53 localhost.localdomain mysqld[26655]: 2018-01-10 10:55:53 140560371275520 [Note] InnoDB: Buf...:53
Jan 10 10:55:53 localhost.localdomain mysqld[26655]: 2018-01-10 10:55:53 140563807148160 [Note] Server sock...:'.
Jan 10 10:55:53 localhost.localdomain mysqld[26655]: 2018-01-10 10:55:53 140563807148160 [Note] Reading of ...ded
Jan 10 10:55:53 localhost.localdomain mysqld[26655]: 2018-01-10 10:55:53 140563807148160 [Note] Added new M...ble
Jan 10 10:55:53 localhost.localdomain mysqld[26655]: 2018-01-10 10:55:53 140563807148160 [Note] /usr/sbin/m...ns.
Jan 10 10:55:53 localhost.localdomain mysqld[26655]: Version: '10.2.12-MariaDB-log' socket: '/var/lib/mysq...ver
Jan 10 10:55:53 localhost.localdomain systemd[1]: Started MariaDB 10.2.12 database server.
Hint: Some lines were ellipsized, use -l to show in full.
12. MariaDB 버전 확인
12-1. root 비밀번호 설정 안한경우
[root@localhost ~]# mysql -e 'show global variables like "version";'
+---------------+---------------------+
| Variable_name | Value |
+---------------+---------------------+
| version | 10.2.12-MariaDB-log |
+---------------+---------------------+
12-2. root 비밀번호를 설정(변경)한 경우
[root@localhost my.cnf.d]# mysql -uroot -p -e 'show global variables like "version";'
Enter password:
+---------------+---------------------+
| Variable_name | Value |
+---------------+---------------------+
| version | 10.2.12-MariaDB-log |
+---------------+---------------------+
13. MariaDB root 접속
[root@localhost ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 12
Server version: 10.2.12-MariaDB-log MariaDB Server
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
초기 비밀번호 설정을 하지 않았다면 패스워드입력없이 엔터만 치면 접속이 가능하다
14. MariaDB Security 설정 ( root 비밀번호 설정하기 )
[root@localhost ~]# /usr/bin/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 current
password for the root user. If you've just installed MariaDB, and
you 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 MariaDB
root user without the proper authorisation.
Set root password? [Y/n] 엔터
New password: 패스워드 입력
Re-enter new password: 패스워드 재입력
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] 엔터
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] 엔터
... Success!
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] 엔터
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] 엔터
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
[root@localhost ~]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@localhost ~]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 150
Server version: 10.1.25-MariaDB MariaDB Server
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
15. 데이터베이스 생성 / 권한 부여 / 접속
https://www.happyjung.com/lecture/2491
16. MariaDB 서버 재시작
[root@localhost ~]# systemctl restart mariadb.service
참고자료
https://blog.bypass.kr/243
https://mariadb.com/kb/en/mariadb/yum/
http://itlift.blogspot.kr/2015/11/centos7-mariadb-yum.html
http://millky.com/@origoni/post/1001?language=ko_kr
https://mariadb.com/kb/en/mariadb/upgrading-from-mysql-to-mariadb/
http://yookeun.github.io/database/2015/07/21/mysql-utf8mb4/
https://www.tecmint.com/install-mariadb-in-centos-7/
댓글목록
hansoncoding님의 댓글
hansoncoding 메일보내기 이름으로 검색 작성일
Transaction Check Error:
file /usr/lib64/libmysqlclient.so.15.0.0 from install of MariaDB-compat-10.1.22-1.el6.x86_64 conflicts with file from package MySQL-shared-compat-5.6.27-1.linux_glibc2.5.x86_64
file /usr/lib64/libmysqlclient.so.16.0.0 from install of MariaDB-compat-10.1.22-1.el6.x86_64 conflicts with file from package MySQL-shared-compat-5.6.27-1.linux_glibc2.5.x86_64
file /usr/lib64/libmysqlclient_r.so.15.0.0 from install of MariaDB-compat-10.1.22-1.el6.x86_64 conflicts with file from package MySQL-shared-compat-5.6.27-1.linux_glibc2.5.x86_64
file /usr/lib64/libmysqlclient_r.so.16.0.0 from install of MariaDB-compat-10.1.22-1.el6.x86_64 conflicts with file from package MySQL-shared-compat-5.6.27-1.linux_glibc2.5.x86_64
이러한 에러나면서 설치가 안되는데 해결 방법 아실까요??ㅠㅠㅠ