더북(TheBook)

8. 로컬 호스트의 포트 33006번을 이용해 MySQL에 접속해 보겠습니다. mysql 명령어를 이용해 -h 옵션 뒤에는 호스트 이름이나 호스트 IP를 입력하고, 대문자 -P 옵션 뒤에는 포트 번호를 입력합니다. -u 옵션 뒤에는 사용자 계정을 입력하고, -p 옵션 뒤에는 패스워드를 입력합니다. MariaDB 프롬프트로 들어가면 show databases 명령어를 이용해 데이터베이스 목록을 확인하고, Playground 데이터베이스로 전환해 테이블 목록도 확인합니다. 그리고 Equipment 테이블에 데이터를 하나 인서트합니다.

root@ubuntu01:~# mysql -h localhost -P 33006 -u root -popenstack
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 12
Server version: 10.1.17-MariaDB-1~xenial mariadb.org binary distribution

Copyright © 2000, 2016, Oracle, MariaDB Corporation Ab and others.

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

MariaDB [(none)]> show databases; +——————–+ | Database | +——————–+ | information_schema | | mysql | | performance_schema | | playground | +——————–+ 4 rows in set (0.00 sec)

MariaDB [(none)]> use playground; 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 [playground]> show tables; +———————-+ | Tables_in_playground | +———————-+ | equipment | +———————-+ 1 row in set (0.00 sec)

MariaDB [playground]> INSERT INTO equipment (type, quant, color) VALUES (“apple”, 5, “red”); Query OK, 1 row affected (0.01 sec)

MariaDB [playground]> quit; Bye

신간 소식 구독하기
뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.