Mysql Basic Operation

Source: Internet
Author: User

Data type
    1. Char 0~255
    2. Varchar 0~65535
    3. Text 0~65535 (only characters are saved)
    4. Longtext 0~4294967295 (only characters are saved)

      Commands and actions (common items) Action options
  • The command should be entered in the English semicolon ";" to indicate the end of the command;
  • In the absence of an end flag, the carriage return is just a command line, without canceling ("\c") until the end flag (";" ) input, enter the unified execution;
  • The table is too long, the query results display is not easy to identify, can be \g control;
  • Input \c can be used to cancel the front input;
  • If the front input a lot of things, the direct cancellation and unfortunately, you can print out the preceding command through \p, copy down to modify, and then enter \c Cancel to re-enter the command.

    Common operation statements

    Creating database: Create Database XXX (db name)
    Delete databases: drop database XXX (database name)
    Display database: Show databases
    Working with databases: select XXX (database name)
    Show Data sheet: Show tables
    Query Top 10: Select ... from ... where ... limit ten;
    To display the column name of a database:
    DESCRIBE xxx
    DESC xxx
    SHOW COLUMNS from xxx
    Select column_name from information_schema.columns where table_name= ' xxx '

    To change the login password of the root user:
      mysql> set password for 用户名@localhost = password(‘新密码‘);   # 或者 mysqladmin -u用户名 -p旧密码 password 新密码 -- 此时不要加分号  mysql> update user set password=password(‘123‘) where user=‘root‘ and host=‘localhost‘;  
    The appropriate action to forget the root user password (go, no trial)
    1. Close the running MySQL service.
    2. Open the DOS window and go to the Mysql\bin directory.
    3. Enter Mysqld-skip-grant-tables carriage return. -skip-grant-tables means skipping permission table authentication when starting the MySQL service.
    4. Open a DOS window again (because the DOS window just can't move), go to the Mysql\bin directory.
    5. Enter MySQL return and, if successful, the MySQL prompt > will appear.
    6. Connection permissions database: use MySQL;.
    7. Change Password: Update user set Password=password ("123") where user= "root"; (don't forget the last semicolon).
    8. Refresh permissions (required steps): flush privileges;.
    9. Quit quit.
    10. Log out of the system, and then enter, using the username root and the new password just set to 123 login.
?

Mysql Basic Operation

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.