MySQL client command line application tip _ MySQL

Source: Internet
Author: User
Tags mysql commands
MySQL client command line application skills graphic-oriented MySQL management tools are everywhere, but it can really speed up and is not a management tool "graph has its table, maybe none of them are more effective than the command line driven by the MySQL client. However, executing a general query requires a lot of keyboard input, and identifying the database you are currently logged on to and quickly monitoring the performance of the database server will become tedious.

Change client prompt

If you run show tables every time to remind yourself which database you have selected can get a dollar, it is estimated that I have become a millionaire now. In fact, when we switch between IDE, shell, and MySQL client prompts on a regular basis, it is easy to get lost without knowing where we are. To fundamentally eliminate this problem, you can use the following prompt command to change the MySQL prompt:

Mysql> prompt mysql (d)>

After the command is executed, the selected database is displayed at the prompt, as shown below:

Mysql (cmdate)>

In addition, we can easily lose the database server we log on to, not to mention the account in use. To solve this problem, use the u and h options to change the prompt settings:

Mysql> prompt mysql (u @ h)>

The command execution result is as follows:

Mysql (root@www.ctocio.com.cn)>

To permanently save the changes, add the following command to the. my. cnf file:

[Mysql] prompt = mysql d>

The database, user, and host options are only a small part of many optional options. For more information, see the MySQL instructions.

Use shell Alias (Alias) to execute frequently-used MySQL commands

Assume that your new web application is gradually entering the application stage, and new users are registered every hour. Just like IPO, you and your colleagues need to pay attention to the number of registered users. However, to execute a simple counting query, you need to constantly log on to and exit MySQL, which is obviously not very cost-effective. If you log on to the server, you can create a shell alias to log on to the MySQL server, select the appropriate database, and execute the count command throughout the process:

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.