티스토리 뷰

MariaDB 설치

$ brew update
$ brew upgrade
$ brew install mariadb

2022.01.16 기준 Server version: 10.6.4-MariaDB Homebrew

mariadb upgrade 방법

$ brew update
$ brew upgrade
$ brew upgrade mariadb

 

MariaDB server 시작

$ brew services start mariadb

==> Tapping homebrew/services
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-services'...
remote: Enumerating objects: 1686, done.
remote: Counting objects: 100% (565/565), done.
remote: Compressing objects: 100% (412/412), done.
remote: Total 1686 (delta 249), reused 373 (delta 140), pack-reused 1121
Receiving objects: 100% (1686/1686), 487.70 KiB | 9.56 MiB/s, done.
Resolving deltas: 100% (725/725), done.
Tapped 1 command (44 files, 623.6KB).
==> Successfully started `mariadb` (label: homebrew.mxcl.mariadb)

 

MariaDB server 연결 및 mysql database 접속

$ sudo mysql -u root
password : macOS superuser password

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.6.4-MariaDB Homebrew

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)]>

 

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]>

 

MariaDB mysql root 암호 변경 : Your-PW에 입력

MariaDB [mysql]> ALTER USER root@localhost IDENTIFIED VIA mysql_native_password USING PASSWORD("Your-PW");

Query OK, 0 rows affected (0.021 sec)

 

MariaDB [mysql]> exit

Bye

 

MariaDB mysql root 연결

$ sudo mysql -u root -p
Password: macOS superuser password
Enter password: mariadb mysql root password

 


MariaDB 간단한 사용법 

1. Database 보기
MariaDB [(none)]> show databases;

+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| test               |
+--------------------+

 

2. mysql 전환
MariaDB [(none)]> use mysql
3. mysql Table 보기
MariaDB [mysql]> show tables;

+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| column_stats              |
| columns_priv              |
| db                        |
| event                     |
| func                      |
| general_log               |
| global_priv               |
| gtid_slave_pos            |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| index_stats               |
| innodb_index_stats        |
| innodb_table_stats        |
| plugin                    |
| proc                      |
| procs_priv                |
| proxies_priv              |
| roles_mapping             |
| servers                   |
| slow_log                  |
| table_stats               |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| transaction_registry      |
| user                      |
+---------------------------+

4. Database 생성하기
MariaDB [mysql]> create database persona_test;
MariaDB [mysql]> show databases;

+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| persona_test       |
| sys                |
| test               |
+--------------------+

 

5. persona_test DB에 table 만들기 : create table [table-name]([field-name] [field-attr], ... ,);
MariaDB [mysql]> use persona_test
MariaDB [persona_test]> create table person(name varchar(20), age integer);
MariaDB [persona_test]> show tables;

+------------------------+
| Tables_in_persona_test |
+------------------------+
| person                 |
+------------------------+

 

 

6. persona_test DB의 person table 상세보기
MariaDB [persona_test]> desc person;

+-------+-------------+------+-----+---------+-------+
| Field | Type        | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| name  | varchar(20) | YES  |     | NULL    |       |
| age   | int(11)     | YES  |     | NULL    |       |
+-------+-------------+------+-----+---------+-------+

 

 

7. person table 삭제하기 : drop table [table-name]
MariaDB [persona_test]> drop table person; 
MariaDB [persona_test]> show tables; 

Empty set (0.001 sec)

 

8. persona_test databse 삭제하기 : drop database [database-name]
MariaDB [persona_test]> use mysql; 
MariaDB [mysql]> show databases;

+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| persona_test       |
| sys                |
| test               |
+--------------------+

 

MariaDB [mysql]> drop database persona_test;
MariaDB [mysql]> show databases;

+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| test               |
+--------------------+

 

9. mariadb 종료
MariaDB [mysql]> exit

Bye

반응형

'OS > macOS' 카테고리의 다른 글

(macOS-Big Sur) brew update Error  (0) 2022.02.09
(macOS) ruby, rbenv, bundler 설치  (0) 2022.01.24
(macOS)[python] virtualenv 가상환경 만들기 : pyenv  (0) 2020.02.26
MacBook Pro 초기 셋팅  (0) 2020.01.09
(macOS)Sublime Text 3 초기 설정  (0) 2019.09.18
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
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
글 보관함