Database/maria

macOS 에 maria db 설치 및 test db 생성

사리생성 2018. 1. 26. 14:39

macOS 에 maria db 설치 및 test db 생성.


0. brew 설치

http://nerdroom.tistory.com/13 <-- 참조.


1. brew을 이용한 maria db 설치

https://mariadb.com/kb/en/library/installing-mariadb-on-macos-using-homebrew/


설치 : brew install mariadb

삭제 : brew uninstall mariadb


2.  maria db 실행.

mysql.server start 

mysql.server stop  

mysql.server status  


3. test db 생성.

https://dev.mysql.com/doc/employee/en/employees-installation.html 참조.


(1) 관련 소스 다운로드

git clone https://github.com/datacharmer/test_db.git


(2) employees 데이터베이스 생성 및 데이터 생성.

mysql -u root -p -t < employees.sql 


생성 확인

MariaDB [employees]> show databases;

+--------------------+

| Database           |

+--------------------+

| employees          |

+--------------------+


(3) 데이터 건수

mysql -u root -p  -t < test_employees_sha.sql

+----------------------+

| INFO                 |

+----------------------+

| TESTING INSTALLATION |

+----------------------+

+--------------+------------------+------------------------------------------+

| table_name   | expected_records | expected_crc                             |

+--------------+------------------+------------------------------------------+

| employees    |           300024 | 4d4aa689914d8fd41db7e45c2168e7dcb9697359 |

| departments  |                9 | 4b315afa0e35ca6649df897b958345bcb3d2b764 |

| dept_manager |               24 | 9687a7d6f93ca8847388a42a6d8d93982a841c6c |

| dept_emp     |           331603 | d95ab9fe07df0865f592574b3b33b9c741d9fd1b |

| titles       |           443308 | d12d5f746b88f07e69b9e36675b6067abb01b60e |

| salaries     |          2844047 | b5a1785c27d75e33a4173aaa22ccf41ebd7d4a9f |

+--------------+------------------+------------------------------------------+


(4) Employees Structure.



설치 참조. 

[mbp118@~]$brew install mariadb

==> Installing dependencies for mariadb: openssl

==> Installing mariadb dependency: openssl

==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2n.high_sierra.bottle.tar.gz

######################################################################## 100.0%

==> Pouring openssl-1.0.2n.high_sierra.bottle.tar.gz

==> Caveats

A CA file has been bootstrapped using certificates from the SystemRoots

keychain. To add additional certificates (e.g. the certificates added in

the System keychain), place .pem files in

  /usr/local/etc/openssl/certs


and run

  /usr/local/opt/openssl/bin/c_rehash


This formula is keg-only, which means it was not symlinked into /usr/local,

because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries.


If you need to have this software first in your PATH run:

  echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile


For compilers to find this software you may need to set:

    LDFLAGS:  -L/usr/local/opt/openssl/lib

    CPPFLAGS: -I/usr/local/opt/openssl/include


==> Summary

🍺  /usr/local/Cellar/openssl/1.0.2n: 1,792 files, 12.3MB

==> Installing mariadb

==> Downloading https://homebrew.bintray.com/bottles/mariadb-10.2.12.high_sierra.bottle.tar.gz

######################################################################## 100.0%

==> Pouring mariadb-10.2.12.high_sierra.bottle.tar.gz

==> /usr/local/Cellar/mariadb/10.2.12/bin/mysql_install_db --verbose --user=mbp118 --basedir=/usr/local/Cellar/mariadb/10.2.12 --datadir=/usr/l

==> Caveats

A "/etc/my.cnf" from another install may interfere with a Homebrew-built

server starting up correctly.


MySQL is configured to only allow connections from localhost by default


To connect:

    mysql -uroot


To have launchd start mariadb now and restart at login:

  brew services start mariadb

Or, if you don't want/need a background service you can just run:

  mysql.server start

==> Summary

🍺  /usr/local/Cellar/mariadb/10.2.12: 640 files, 170MB

[mbp118@~]$ 


[mbp118@~]$ mysql.server start

Starting MySQL

.180131 18:04:32 mysqld_safe Logging to '/usr/local/var/mysql/MBP118ui-MacBook-Pro.local.err'.

180131 18:04:32 mysqld_safe Starting mysqld daemon with databases from /usr/local/var/mysql

 SUCCESS! 

[mbp118@~]$  


[mbp118@~/Downloads/test_db]$ mysql -u root -p -t < employees.sql 

Enter password: 

+-----------------------------+

| INFO                        |

+-----------------------------+

| CREATING DATABASE STRUCTURE |

+-----------------------------+

+------------------------+

| INFO                   |

+------------------------+

| storage engine: InnoDB |

+------------------------+

+---------------------+

| INFO                |

+---------------------+

| LOADING departments |

+---------------------+

+-------------------+

| INFO              |

+-------------------+

| LOADING employees |

+-------------------+

+------------------+

| INFO             |

+------------------+

| LOADING dept_emp |

+------------------+

+----------------------+

| INFO                 |

+----------------------+

| LOADING dept_manager |

+----------------------+

+----------------+

| INFO           |

+----------------+

| LOADING titles |

+----------------+

+------------------+

| INFO             |

+------------------+

| LOADING salaries |

+------------------+

+---------------------+

| data_load_time_diff |

+---------------------+

| 00:00:24            |

+---------------------+

[mbp118@~/Downloads/test_db]$  


 [mbp118@~/Downloads/test_db]$ mysql -u root -p

Enter password: 

Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MariaDB connection id is 11

Server version: 10.2.12-MariaDB Homebrew


Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.


Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


MariaDB [(none)]> use employees;

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 [employees]> show tables;

+----------------------+

| Tables_in_employees  |

+----------------------+

| current_dept_emp     |

| departments          |

| dept_emp             |

| dept_emp_latest_date |

| dept_manager         |

| employees            |

| salaries             |

| titles               |

+----------------------+

8 rows in set (0.00 sec)


MariaDB [employees]> 


'Database > maria' 카테고리의 다른 글

FIND_IN_SET  (0) 2023.12.28
explain  (0) 2018.01.30
foreign-keys  (0) 2018.01.30
mysql profiling  (0) 2018.01.29
window functions 윈도우 함수.  (0) 2018.01.26