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: