หน้าเว็บ

Tuesday, November 13, 2012

Connecting to and Disconnecting from the Server

To be able to connect and disconnect a MySQL server to query any data like this:
shell> mysql -h host -u user -p
Enter password: ********
.
.
.
mysql>
mysql>
mysql> quit
Bye
mysqlthe program that is invoked
-h hosthost represent the host name where your MySQL server is running (if host is localhost, you can omit this option)
-u useruser represent the user name of your MySQL account
-pto enter password of user at the "Enter password:" prompt.
quit or \qexit MySQL program (On Unix, you can also disconnect by pressing Control+D.)


Example:
C:\>
C:\>mysql -h localhost -u root -p
Enter password: ********
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.27 MySQL Community Server (GPL)

Copyright (c) 2000, 2011, 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>
mysql>
mysql> quit
Bye

C:\>

Refer to:MySQL Document as "refman5-5"

No comments:

Post a Comment