MySQL database technology (06) [group chart] _ MySQL

Source: Internet
Author: User
Tags mysql command line
MySQL database technology (06) [group chart] 1.5 skills for interacting with mysql

This section describes how to interact with the mysql client program more effectively and with less input workload. This section describes how to connect to the server more easily, and how to avoid entering the query from the beginning each time.

1.5.1 simplify the connection process

When activating mysql, you may need to specify connection parameters such as the host name, user name, or password. Running a program requires a lot of input work, which will soon be annoying. There are several ways to minimize the input work, making the connection easier. they are:

■ Use option files to store connection parameters.

■ Repeat commands using shell commands.

■ Define the mysql command line shortcut using the shell alias or script.

1. use the option file

MySQL allows you to store connection parameters in an option file since MySQL 3.22. Then, you do not need to repeat these parameters when running mysql. it can be used only when you have typed them on the command line. These parameters can also be used by other MySQL clients, for example, mysqlimport. This also means that the option file reduces the typing workload when using these programs. To use the option file method to specify the connection parameter, you can create a parameter named ~ /. M y. cnf (a file named. m y. cnf in the main directory ). The option file is a non-formatted text file, so it can be created using any text editor. The file content is as follows:

The [client] line marks the beginning of the guest Group. all the rows followed by it are prepared for the MySQL client program to obtain the option value, these rows continue until the end of the file or the beginning of another different parameter group. When connecting to the server, replace s e r v e r h o s t, yourname, and y o u r p a s with the specified host name, user name, and password. For the author,. m y. cnf is as follows:

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.