To newbie --- MySQL application prelude if MYSQL runs on the server and you need to connect to the client, you need to connect as follows:
Shell> mysql-h host-u user-p
Enter password :************
Host and user indicate the host name and MySQL account name running on the MySQL server respectively. enter the name of the corresponding machine and the MySQL user name. ******** indicates your password.
If valid, you will see the following prompt:
Welcome to the MySQL monitor. Commands end with; or g.
Your MySQL connection id is 7 to server version: 5.0.18-nt
Type 'help; 'or 'H' for help. Type 'C' to clear the buffer.
Mysql>
Mysql> the prompt tells you to enter the command.
Sometimes MySQL allows you to log on to the server anonymously, and you can directly enter mysql.
Shell> mysql
After successful connection, you can enter quit at the mysql> prompt to exit at any time:
Mysql> quit
Bye
The following shows a simple query instance. this is a simple command that requires the server version number and current date:
Mysql> select version (), current_date;
+ ----------- + -------------- +
Version () current_date
+ ----------- + -------------- +
5.0.18-nt 2006-07-29
+ ----------- + -------------- +
1 row in set (0.00 sec)
Mysql>
Here we need to understand:
A command is usually composed of SQL statements followed by a semicolon.
MySQL displays results in tables (rows and columns. the label of the first Behavior column and the result of the subsequent behavior query. the column label is the name of the database table you query. However, if you search for an expression rather than a column value (in the preceding example), the column is usually marked by the expression itself.
Then it will show how many rows are returned and the query time. It provides a rough estimate of the server performance. it indicates that the clock time is not the CPU or machine time.
The keyword can be entered in upper or lower case, that is, it is equivalent in MySQL, but in a query statement, the case must be unified.
The following is another query:
Mysql> select sin (PI ()/4), (4 + 1) * 5;
+ ------------------ + --------- +
SIN (PI ()/4) (4 + 1) * 5
+ ------------------ + --------- +
0.70710678118655 25
+ ------------------ + --------- +
1 row in set (0.02 sec)
Mysql>