MySQL과 MariaDB는 처음 설치하면 root 계정의 설정이되어 있지 않아. 꼭 처음에 root 설정을 진행해야 합니다.
0. MySQL, MariaDB root 비밀번호 설정 Test 환경
1
2
3
4
|
[root@mariadb-master ~]# cat /etc/centos-release
CentOS Linux release 7.3.1611 (Core)
[root@mariadb-master ~]# mysql --version
mysql Ver 15.1 Distrib 10.2.32-MariaDB, for Linux (x86_64) using readline 5.1
|
cs |
1. MySQL, MariaDB 접속 확인
초기에는 비밀번호가 없기 때문에 바로 접속되는 모습을 확인할 수 있다.
1
2
3
4
5
6
7
8
9
10
11
|
[root@mariadb-master ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 10.2.32-MariaDB-log 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)]>
|
cs |
2. root 계정 정보 확인
database mysql에 계정정보가 담아져 있고 user table을 확인하면 된다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
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]> show tables like 'user';
+------------------------+
| Tables_in_mysql (user) |
+------------------------+
| user |
+------------------------+
1 row in set (0.00 sec)
MariaDB [mysql]> select host, user, password from user;
+----------------+------+----------+
| host | user | password |
+----------------+------+----------+
| localhost | root | |
| localhost | | |
| mariadb-master | | |
+----------------+------+----------+
3 rows in set (0.00 sec)
|
cs |
3. root 계정 초기 설정
update 쿼리를 통해서 root 에 비밀번호를 설정해주면 완료~
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
MariaDB [mysql]> update user set password=password('new-password') 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.00 sec)
MariaDB [mysql]> select host, user, password from user;
+----------------+------+-------------------------------------------+
| host | user | password |
+----------------+------+-------------------------------------------+
| localhost | root | *FE77F6274099B26A5DD565E9898AA22FF1A714BC |
| localhost | | |
| mariadb-master | | |
+----------------+------+-------------------------------------------+
3 rows in set (0.00 sec)
|
cs |
'Database > Database 명령어' 카테고리의 다른 글
MySQL MariaDB 계정 관리/권한설정/외부접근 (1) | 2020.06.11 |
---|
댓글