Real MariaDB (2017년)
서버 로그인 0 0 37,874

by 구루비스터디 mysql 실행 mysql 로그인 [2019.08.11]


3.2 서버 로그인


# 로컬 로그인
[root@localhost mysql]# mysql -u root -p

# 원격지 로그인 시
[root@localhost mysql]# mysql -h 127.0.0.1 -P 3306 -u root -p



# 연결 정보 조회
MariaDB [(none)]> \s
--------------
mysql  Ver 15.1 Distrib 10.1.22-MariaDB, for Linux (x86_64) using readline 5.1

Connection id:		3
Current database:
Current user:		root@localhost
SSL:			Not in use
Current pager:		stdout
Using outfile:		''
Using delimiter:	;
Server:			MariaDB
Server version:		10.1.22-MariaDB MariaDB Server
Protocol version:	10
Connection:		127.0.0.1 via TCP/IP
Server characterset:	latin1
Db     characterset:	latin1
Client characterset:	utf8
Conn.  characterset:	utf8
TCP port:		3306
Uptime:			3 min 39 sec

Threads: 1  Questions: 6  Slow queries: 0  Opens: 17  Flush tables: 1  Open tables: 11  Queries per second avg: 0.027
--------------



# 안전모드로 mysql 클라이언트 실행
[root@localhost mysql]# mysql -u root -p --safe-updates;
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 5
Server version: 10.1.22-MariaDB MariaDB Server

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

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

MariaDB [(none)]> use test;
Database changed
MariaDB [test]> create table test_table(uid int);      <---- 가능
Query OK, 0 rows affected (0.01 sec)

MariaDB [test]> insert into test_table values (1);     <---- 가능
Query OK, 1 row affected (0.01 sec)

MariaDB [test]> select * from test_table;               <---- 가능
+------+
| uid  |
+------+
|    1 |
+------+
1 row in set (0.00 sec)

MariaDB [test]> delete from test_table;      <--- 불가능
ERROR 1175 (HY000): You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
MariaDB [test]> update test_table set uid = 2;   <---- 불가능
ERROR 1175 (HY000): You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column



# 쿼리문 실행 시 --execute 옵션 사용
[root@localhost mysql]# mysql -u root -p -D test --execute="select * from test_table"
Enter password:
+------+
| uid  |
+------+
|    1 |
+------+


"구루비 데이터베이스 스터디모임" 에서 2017년에 "Real MariaDB" 도서를 스터디하면서 정리한 내용 입니다.

- 강좌 URL : http://www.gurubee.net/lecture/4182

- 구루비 강좌는 개인의 학습용으로만 사용 할 수 있으며, 다른 웹 페이지에 게재할 경우에는 출처를 꼭 밝혀 주시면 고맙겠습니다.~^^

- 구루비 강좌는 서비스 제공을 위한 목적이나, 학원 홍보, 수익을 얻기 위한 용도로 사용 할 수 없습니다.

댓글등록
SQL문을 포맷에 맞게(깔끔하게) 등록하려면 code() 버튼을 클릭하여 작성 하시면 됩니다.
로그인 사용자만 댓글을 작성 할 수 있습니다. 로그인, 회원가입