Documentation MySQL 8.0 Reference Manual - Tutorial - Connecting to and Disconnecting from the Server
MySQL 8.0 Reference Manual - Tutorial 1
3.1 Connecting to and Disconnecting from the Server
shell> mysql -h host -u user -p Enter password: ********
위의 사용에서 -h 는 host를 가리키며 -u 는 유저, -p 는 패스워드를 가리킨다.
C:\Users\User>mysql -h localhost -u root -p Enter password: ******* Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 17 Server version: 8.0.17 MySQL Community Server - GPL Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
서버가 시작되어 있지 않았을 때 접속을 시도하면 아래와 같은 에러를 만나게 된다.
C:\Users\User>mysql -h localhost -u root -p Enter password: ******* ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061) C:\Users\User>
또는 아래와 같은 에러를 만나게 된다.(daemon으로 수행되는 방식인 unix 나 linux에서)
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)