The last chapter on how to install and test MySQL, the environment can be built to continue our study. This article is mainly familiar with the writing of common commands.
1, start the MySQL server
In fact, the previous article has talked about how to start MySQL. Two ways:
The first is to use Winmysqladmin, if the machine is started automatically run, you can go directly to the next operation.
The second is to run in DOS mode
D:mysqlbinmysqld
2, access to the MySQL interactive operation interface
In DOS mode, run:
D:mysqlbinmysql
Appear:
Mysql
Prompt, which has already entered the interactive operation of MySQL.
If "Error 2003:can ' t connect to MySQL server ' localhost ' (10061)" appears,
Shows that your MySQL has not yet started.
3, exit the MySQL operation interface
Enter quit at the mysql> prompt to exit the interactive interface at any time:
Mysql> quit
Bye
You can also use control-d to exit.
4. The first Order
Mysql> Select Version (), current_date ();
+----------------+-----------------+
| Version () | Current_date () |
+----------------+-----------------+
| 3.23.25a-debug | 2001-05-17 |
+----------------+-----------------+
1 row in Set (0.01 sec)
Mysql>
This command requires the MySQL server to tell you its version number and current date. Try the above command in a different case to see what the results are.
The results show that the case of the MySQL command is consistent.
Practice the following actions:
Mysql>select (20+5) *4;
Mysql>select (20+5) *4,sin (Pi ()/3);
Mysql>select (20+5) *4 as Result,sin (Pi ()/3); (as: Specify Kana as result)
5, Multiline statement
A command can be entered into multiple lines until the semicolon ";" appears:
Mysql> Select
-> USER ()
->,
-> Now ()
->;
+--------------------+---------------------+
| USER () | Now () |
+--------------------+---------------------+
| Odbc@localhost | 2001-05-17 22:59:15 |
+--------------------+---------------------+
1 row in Set (0.06 sec)
Mysql>
Notice how the middle comma and the last semicolon are used.
6, one-line command
Enter the following command:
Mysql> SELECT USER (); SELECT now ();
+------------------+
| USER () |
+------------------+
| Odbc@localhost |
+------------------+
1 row in Set (0.00 sec)
+---------------------+
| Now () |
+---------------------+
| 2001-05-17 23:06:15 |
+---------------------+
1 row in Set (0.00 sec)
Mysql>
Notice the semicolon in the middle and separate the commands with semicolons.
7, display the current existing database
mysql> show databases;
+----------+
| Database |
+----------+
| MySQL |
| Test |
+----------+
2 row in Set (0.06 sec)
Mysql>
8, select the database and display the currently selected database
mysql> use MySQL
Database changed
Mysql>
(Use and QUIT commands do not require a semicolon to end.) )
Mysql> Select Database ();
+---------------+
| Database () |
+---------------+
| MySQL |
+---------------+
1 row in Set (0.00 sec)
9, display the table existing in the current database
Mysql> show TABLES;
10, display the contents of the table (db)
Mysql>select * from DB;
11, the cancellation of the order
When the command enters an error and cannot change (multiline statement case), you can cancel the command with C before the semicolon appears
Mysql> Select
-> User ()
-> C
Mysql>
This is some of the most commonly used the most basic operation commands, through many exercises can be firmly covered with the palm.
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