MySQL Common command operation

Source: Internet
Author: User

1. Command line login using the default 3306 port of MySQL:

  Mysql-u root-p

2. Manage multiple MySQL on different ports via a TCP connection (note: This feature is only available for MySQL4.1 or later versions):

  Mysql-u root-p--protocol=tcp--host=localhost--port=3307

3. Manage multiple MySQL on different ports via socket sockets:

  Mysql-u root-p--socket=/tmp/mysql3307.sock

4. Manage multiple MySQL on different ports via port and IP:

  Mysql-u root-p-P 3306-h 127.0.0.1

5. Repair the damaged table (the table to be repaired in this example is T_user):

  Repair table T_user;

6. MySQL Changes the root password to sa123:

  Mysqladmin-u root-p 123 Password sa123

7. Add a user test1 password to ABC, so that he can log on any host, and all databases have query, insert, modify, delete permissions.

First connect to MySQL with the root user, and then type the following command:

  Grant Select,insert,update,delete on * * to [[email protected] '%][email protected] '%[/email] ' identified by ' ABC ';

8. Start from line No. 0 and take 3 lines:

  SELECT * FROM student limit 0, 3;

9. View the current database encoding:

  Show variables like ' character_set_database ';

10. Modify the database encoding (XXX is the database name):

  ALTER DATABASE XXX CHARACTER SET UTF8;

MySQL Common command 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.