티스토리 뷰

DB/MariaDB

MariaDB_install

<oblivion/> 2023. 2. 26. 19:48

[docker pull & start]

docker  run -d -p 13306:3306 -e MYSQL_ROOT_PASSWORD=pwd123 -v "c:/dockers/vols/mariadb:/var/lib/mysql" --name mariadb_local mariadb:latest

 

[DB/ User/ Table  생성]

$ docker exec -it mariadb_local bash

root@6de08339549c:/# mysql -u root -p

Enter password: pwd123

 

 

MariaDB [(none)]> create database DBT1;
Query OK, 1 row affected (0.018 sec)

MariaDB [(none)]> create user 'mt1'@'%' identified by 'mt1234';
Query OK, 0 rows affected (0.009 sec)

MariaDB [(none)]> grant all privileges on DBT1.* to 'mt1'@'%';
Query OK, 0 rows affected (0.005 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.003 sec)

 

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| DBT1               |
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.045 sec)

 

 

MariaDB [DBT1]> create table if not exists t2 (
    ->     uid bigint auto_increment primary key,
    ->     uname varchar(128) charset utf8
    -> ) engine=InnoDB default charset utf8;
Query OK, 0 rows affected (0.018 sec)

 

 

MariaDB [DBT1]> SHOW CREATE TABLE dbt1.t2;
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table
                                                                       |
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t2    | CREATE TABLE `t2` (
  `uid` bigint(20) NOT NULL AUTO_INCREMENT,
  `uname` varchar(128) DEFAULT NULL,
  PRIMARY KEY (`uid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci |

 

MariaDB [DBT1]> insert into t2(uname) values('tom');
Query OK, 1 row affected (0.003 sec)

MariaDB [DBT1]> select * from t2;
+-----+-------+
| uid | uname |
+-----+-------+
|   1 | tom   |
+-----+-------+
1 row in set (0.001 sec)

 

 

 

 

 

 

 

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/12   »
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
글 보관함