การ login เข้าสู่ MySQL

       เมื่อได้ติดตั้ง MySQL ตลอดจน test แล้วว่า Programe ทำงานจนมั่นใจแล้ว ทีนี้เราก็จะเข้าสู่ MySQL กันเสียที การเข้าสู่ MySQL สามารถทำได้หลายทางทั้งทาง Client โดยการใช้ Telnet เข้ามา หรือ เข้าทาง Consol โดย Login เป็น user ต่างๆ แต่ผู้เขียนขอแนะให้ login เข้ามาทาง telnet จะดีกว่า 
       ก่อนอื่นจะต้องทำการกำหนด mysqladmin เพื่อความปลอดภัยของระบบ โดย mysqladmin เท่านั้นที่สามารถเข้าสู่ MySQL ได้ 

       รูปแบบคำสั่งมีดังนี้
       #/usr/local/bin/mysqladmin -u root password secret
      -u ตามด้วยชื่อ user      หมายถึงการกำหนดชื่อ user
       password ตามด้วย password    หมายถึงการกำหนด password ให้กับ user ดังกล่าวข้างต้น

       จะสังเกตได้ว่าช่วงที่กำหนด password ให้กับ user นั้น เราจะเห็น password ตอน key ดังนั้น ตอนกำหนด password จะต้องระมัดระวังด้วย
       ทีนี้เราก็มา login เข้า MySQL กันเสียที โดยมี

       รูปแบบคำสั่งมีดังนี้
      #/usr/local/bin/mysql -u root password
      Enter password: ********  (ให้ใส่ password ที่กำหนดลงไป)
 

#/usr/local/bin/mysql -u root password
Enter password: ********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 459 to server version: 3.22.20a-log
Type 'help' for help.
mysql>

      เมื่อ login เข้ามาใน MySQL แล้ว จะมีเครื่องหมายพร้อม ดังนี้ mysql>
      การออกจาก MySQL มีรูปแบบคำสั่งดังนี้
     mysql> QUIT
 

mysql> QUIT
Bye

Tip นอกจากนี้เรายังขอความช่วยเหลือจาก MySQL ได้ด้วยคำสั่ง help ดังเช่นตัวอย่าง
 

mysql> help

MySQL commands:
help    (\h)    Display this text
?       (\h)    Synonym for `help'
clear   (\c)    Clear command
connect (\r)    Reconnect to the server. Optional arguments are db and host
edit    (\e)    Edit command with $EDITOR
exit    (\)     Exit mysql. Same as quit
go      (\g)    Send command to mysql server
print   (\p)    print current command
quit    (\q)    Quit mysql
rehash  (\#)    Rebuild completion hash
status  (\s)    Get status information from the server
use     (\u)    Use another database. Takes database name as argument

Connection id: 6  (Can be used with mysqladmin kill)

mysql> 

      ในรายละเอียดของ help คือ
       columm แรก เป็นคำสั่ง
       columm ที่สองเป็น short key เราสามารถพิมพ์ short key ได้เลยซึ่งมีผลเท่ากับคำสั่งเช่นพิมพ์ \q มีค่าเท่ากับ quit
       columm  ที่สามเป็นคำอธิบาย


Copyright By Passkorn Roungrong 2000