Linux

리눅스 Ubuntu 18.04에 MariaDB 설치 방법

이비담 2019. 11. 1. 14:14

- AWS Ubunt 18.04 MariaDB-10.2 셋팅 메뉴얼

// MariaDB Open Key 추가
sudo apt-get install software-properties-common
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] http://mirror.host.ag/mariadb/repo/10.2/ubuntu bionic main'

// 설정한 repository 적용을 위한 업데이트 및 MariaDB 설치
sudo apt update
sudo apt install mariadb-server

// MariaDB 설치
sudo apt-get install mariadb-server-10.2

sudo mysql -u root -p
Enter password: 암호 입력(미지정시 엔터)

MariaDB [(none)]> SELECT User, Host, Plugin FROM mysql.user;
+------+-----------+-------------+
| User | Host      | Plugin      |
+------+-----------+-------------+
| root | localhost | unix_socket |
+------+-----------+-------------+

unix_socket 상태일시

MariaDB [(none)]> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [mysql]> update user set plugin ='' where User='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.01 sec)
MariaDB [mysql]> exit;
Bye

이용하여 unix_socket 해제
해결되지않을시
sudo systemctl stop mariadb
sudo mysqld_safe --skip-grant-tables &
mysql -u root 를 사용하여 접속

// 계정생성 및 권한부여
use mysql;
MariaDB [mysql]> GRANT ALL PRIVILEGES ON *.* TO '아이디'@'%' IDENTIFIED BY '패스워드' REQUIRE NONE WITH GRANT OPTION;
Query OK, 0 rows affected (0.01 sec)

// DB 생성
sudo mysql -u root
create database 생성할 데이터베이스명;

// DB 생성 확인
show databases;

// DB 복원
mysql -uroot -p 생성한 데이터베이스명 < /경로지정/복원파일명.sql

// 포트 오픈 및 테이블 대소분자 구분 제거
cd /etc/mysql
ubuntu@ip-172-31-39-47:/etc/mysql$ ls
conf.d  debian-start  debian.cnf  mariadb.conf.d  my.cnf

sudo vi my.cnf

[mysqld]
bind-adress 127.0.0.1 -> 0.0.0.0 수정
lower_case_table_names = 1 추가

// MariaDB 재실행
sudo service mysql restart

 

AWS EC2 프리티어 Ubuntu 18.04에서 설치 하였음