Learn common MySQL operation commands

Source: Internet
Author: User
This article is familiar with Common commands. 1. Start the MySQL server. In fact, the previous article describes how to start MySQL. Two Methods: one is to use winmysqladmin. If the machine runs automatically at startup, you can directly go to the next step. Second, Run d: mysqlbinmysqld2 in DOS mode. Enter the mysql interactive operation interface. In DOS mode, run

This article is familiar with Common commands. 1. Start the MySQL server. In fact, the previous article describes how to start MySQL. Two Methods: one is to use winmysqladmin. If the machine runs automatically at startup, you can directly go to the next step. Second, Run d: mysqlbinmysqld in DOS mode. 2. Enter the mysql interactive operation interface. In DOS mode, run

This article is familiar with Common commands.
1. Start the MySQL server
In fact, the previous article describes how to start MySQL. Two Methods: one is to use winmysqladmin. If the machine runs automatically at startup, you can directly go to the next step. Second, Run d: mysqlbinmysqld in DOS mode.
2. Enter the mysql interactive operation interface
In DOS mode, run: d: mysqlbinmysql to display: mysql prompt. The interactive operation mode of mysql has been entered. If "ERROR 2003: Can't connect to MySQL server on 'localhost' (10061)" appears, your MySQL has not been started.
3. Exit the MySQL operation interface.
Enter quit at the mysql> prompt to exit the interactive operation interface at any time: mysql> quit Bye. You can also use control-D to exit.
4. The first command
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. Run the preceding command in different cases to check the result. The results show that the case sensitivity of the mysql Command is consistent. Perform the following operations:
Mysql> Select (20 + 5) * 4; mysql> Select (20 + 5) * 4, sin (pi ()/3); mysql> Select (20 + 5) * 4 AS Result, sin (pi ()/3); (AS: Specifies the alias AS Result)5. Multi-line statementsA command can be input in multiple lines until the Semicolon ";" is displayed:
 
  

  
 
       
        
Mysql> select-> USER ()->,-> now ()->; + -------------------- + --------------------- + | USER () | now () | + -------------------- + ------------------- + | ODBC @ localhost | 22:59:15 | + ------------------------ + --------------------- + 1 row in set (0.06 sec) mysql> note the use of commas (,) and semicolons (,) in the middle. 6. Run the following command in one line: mysql> select user (); select now (); + ---------------- + | USER () | + ------------------ + | ODBC @ localhost | + ------------------ + 1 row in set (0.00 sec) + --------------------- + | NOW () | + --------------------- + | 23:06:15 | + ----------------------- + 1 row in set (0.00 sec) mysql> note the semicolons in the middle, which are separated by semicolons. 7. display the current Database mysql> show databases; + ---------- + | Database | + ---------- + | mysql | test | + ---------- + 2 row in set (0.06 sec) mysql> 8. Select a Database and display the currently selected Database mysql> USE mysql Database changed mysql> (USE and QUIT commands do not need to end with a semicolon .) Mysql> select database (); + --------------- + | database () | + ----------------- + | mysql | + --------------- + 1 row in set (0.00 sec) 9. display the TABLES in the current database mysql> show tables; 10. display the table (db) content mysql> select * from db; 11. Command cancellation when the command input is incorrect and cannot be changed (multi-line statements, you can use c to cancel the command mysql> select-> user ()-> c mysql> before the semicolon appears.
       
This is some of the most commonly used basic operation commands. you can stick to it after multiple exercises.

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.