Introduction to MySQL, learning and navigation for beginners

Source: Internet
Author: User
If you are new to the MySQL database, you will certainly have some difficulties in learning it. The following articles are mainly for new users, that is, the prelude to using MySQL, if you are interested in the content related to the prelude used by MySQL, you can view the following articles. To newbie --- a prelude to MySQL: If MySQL (and

If you are new to the MySQL database, you will certainly have some difficulties in learning it. The following articles are mainly for new users, that is, the prelude to using MySQL, if you are interested in the content related to the prelude used by MySQL, you can view the following articles. To newbie --- a prelude to MySQL: If MySQL (and

If you are new to the MySQL database, you will certainly have some difficulties in learning it. The following articles are mainly for new users, that is, the prelude to using MySQL, if you are interested in the content related to the prelude used by MySQL, you can view the following articles.

To newbie --- prelude 1 For MySQL:

If MySQL (the best combination with PHP) runs on the server, and you need to connect to the client, you need to connect as follows:

Shell> MySQL (best combination with PHP)-h host-u user-p

Enter password :************

Host and user represent the host name and the account name of the MySQL (the best combination with PHP) server running. enter the name of the corresponding machine and the username of MySQL (the best combination with PHP. * ******** represents your password.

If valid, you will see the following prompt:

Welcome to the MySQL (the best combination with PHP) monitor. Commands end with; or \ g.

Your MySQL (best combination with PHP) connection id is 7 to server version: 5.0.18-nt

Type 'help; 'or' \ H' for help. Type '\ C' to clear the buffer.

MySQL (the best combination with PHP)>

MySQL (the best combination with PHP)> The prompt tells you that the command should be entered.

Sometimes MySQL (the best combination with PHP) allows you to log on to the server anonymously, and enter MySQL (the best combination with PHP) directly.

Shell> MySQL (best combination with PHP)

After successful connection, you can enter quit at any time at the MySQL (best combination with PHP)> prompt to exit at any time:

MySQL (best combination with PHP)> quit

Bye

To newbie --- MySQL Example 2:

Display a simple query instance. This is a simple command that requires the server version number and current date:

 
 
  1. MySQL (the best combination with PHP)> select version (), current_date;
  2. + ----------- + -------------- +
  3. Version () current_date
  4. + ----------- + -------------- +
  5. 5.0.18-nt 2006-07-29
  6. + ----------- + -------------- +
  7. 1 row in set (0.00 sec)

MySQL (the best combination with PHP)>

Here we need to understand:

A command is usually composed of SQL statements followed by a semicolon.

The Display Results of MySQL (the best combination with PHP) are output in the form of 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 and lower case, that is, in MySQL (the best combination with PHP), the upper and lower case are equivalent, but in a query statement, the case must be unified.

The following is another query:

 
 
  1. MySQL (best combination with PHP)> select sin (PI ()/4), (4 + 1) * 5;
  2. + ------------------ + --------- +
  3. SIN (PI ()/4) (4 + 1) * 5
  4. + ------------------ + --------- +
  5. 0.70710678118655 25
  6. + ------------------ + --------- +
  7. 1 row in set (0.02 sec)

MySQL (the best combination with PHP)>

You can enter multiple statements on one line, such:

 
 
  1. MySQL (the best combination with PHP)> select version (); select now ();
  2. + ----------------- +
  3. VERSION ()
  4. + ----------------- +
  5. 5.1.2-alpha-log
  6. + ----------------- +
  7. 1 row in set (0.00 sec)
  8. + --------------------- +
  9. NOW ()
  10. + --------------------- +
  11. 15:15:00
  12. + --------------------- +
  13. 1 row in set (0.00 sec)

MySQL (the best combination with PHP)>

A long command can be input in multiple lines. MySQL (the best combination with PHP) uses a semicolon to determine whether the statement ends, rather than line feed.

To newbie --- prelude 3 for MySQL:

Is an example of a simple multi-line statement:

 
 
  1. MySQL (best combination with PHP)> select
  2. -> User (),
  3. -> Current_date;
  4. + --------------- + -------------- +
  5. USER () CURRENT_DATE
  6. + --------------- + -------------- +
  7. Jon @ localhost 2005-10-11
  8. + --------------- + -------------- +

MySQL (the best combination with PHP)>

In this example, after entering the first line of multi-row query, you can see the prompt changes to->, which means MySQL (the best combination with PHP) the statement end identifier is not found and is waiting for the remaining input. if you do not want to execute a command in the input process, enter \ c to cancel it:

MySQL (best combination with PHP)> select

-> User ()

-> \ C

MySQL (the best combination with PHP)>

The following shows the statuses of each prompt and the MySQL (the best combination with PHP) They represent:

Prompt description

MySQL (the best combination with PHP)> is ready to accept new commands.

-> Wait for the next line of the multi-line command.

'> Wait for the next line, and wait for the end of the string starting with a single quotation mark.

"> Wait for the next line, and wait for the end of the string starting with double quotation marks.

'> Wait for the next line, and wait for the end of the identifier starting with the reverse oblique point.

/*> Wait for the next line and wait for the end of comments starting.

The above content is a prelude to the use of MySQL, a beginner. I hope you will get something.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.