Summary of common mysql commands and summary of common mysql commands

Source: Internet
Author: User

Summary of common mysql commands and summary of common mysql commands

Set and change the password of mysqlroot

The first time you enter the mysql database,

!

You can add the absolute mysql path to the environment variable,


You can also set boot loading,


Reload environment variables to make mysql take effect


Log on to mysql-uroot again.

Add a password to mysql


Log On again for verification,


Change Password


Login again for verification. Verification Successful


Reset the password, modify the configuration file, and skip authorization.


Restart the mysql service and use the root user to verify that no password is required.


Enter and modify the password file

update user set password=password('aminglinux') where user='root';

Modify my. conf after exiting

Delete the above authorization skipping File

Restart the mysqld service

Re-enter mysql Verification

Connect to mysql

Method 1: Use the tcpip Protocol ip: Port, applicable to remote ip, this example is the local machine Experiment


Method 2: Use socket (provided that sock is configured in my. conf), which is only applicable to the local machine.


Method 3: Use the command line, suitable for use with shell scripts

Mysql Common commands

Query databaseShow databases;

Switch DatabaseUse mysql;

View the table in the databaseShow tables;


View fields in the tableDesc tb_name;


View table creation statementsShow create table tb_name \ G;


View Current UserSelect user ();


View the currently used databaseSelect databsase ();

Create a databaseCreate database db1;


Create a tableUse db1; create table t1 (idInt (4 ),nameChar (40) ENGINE = InnoDB default charset = utf8;


Delete tableDrop table t1;

View the current database versionSelect version ();


View database statusShow status;


View ParametersShow variables; with show variables like 'max _ connect % ';


Modify parametersSet global max_connect_errors = 1000; you can also modify it in/etc/my. conf.


View queues show processlist; show full processlist;

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.