원하는 버전의 mariadb를 다운받고 싶다면
https://downloads.mariadb.org/
여기로 접속해서 원하는 mariadb 버전을 선택한후
MariaDBYUM 저장소 항목을 복사하여
cat > MariaDB.repo
이곳에 넣어준다
이후
sudo yum install MariaDB-server MariaDB-client
명령어를 입력하면 원하는 버전의 mariadb가 설치된다!!
systemctl enable mariadb
mariadb를 허용하고
systemctl start mariadb
mariadb를 시작하면
[root@server1 yum.repos.d]# systemctl status mariadb
● mariadb.service - MariaDB 10.2.39 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 2021-07-14 11:09:27 KST; 5s ago
다음과 같이 mariadb가 활성화된 것을 확인할 수 있다
mariadb를 외부에서도 사용할 수 있게 하려면 port를 열어줘야 한다
기존에 만들었던 쉘 firewall.sh를 활용하자!!
#!/bin/bash
echo 'input service: '
read serv
echo 'input port#: '
read port
firewall-cmd --add-service=port/tcp --permanent --zone=public
firewall-cmd --reload
firewall-cmd --list-all
서비스 이름과 포트 번호를 입력해주면
포트를열 수 있다!!
service= mysql
port= 3306
mysql 접속
[root@server1 /]# mysql -uroot
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.2.39-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.
접속되는 것을 확인할 수 있다!!
비밀번호 설정
[root@server1 /]#/usr/bin/mysql_secure_installation
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] y
Disallow root login remotely? [Y/n] n
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
비밀번호 설정 후
[root@server1 /]# mysql -uroot
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
접속이 실패하는 것을 볼 수 있다
[root@server1 /]# mysql -uroot -p
Enter password:
패스워드를 입력하면 접속 성공!!
mysql을 윈도우에 워크벤치에서 접속하려면
mysql -uroot -p
insert into mysql.user(host,user,password,ssl_cipher,x509_issuer,x509_subject,authentication_string) values ('192.168.%','root',password('password'),'','','','');
grant all privileges on . to 'root'@'192.168.%';
select host,user,password from mysql.user;
flush privileges;
를 리눅스에 입력하고
워크벤치에 vm ip와 포트 비밀번호를 입력해주면된다!!!