MySQL optimization Overview-server parameter adjustment-MySQL

Source: Internet
Author: User
Correct compilation methods are important, but they are only part of improving MySQL server performance. Many MySQL server parameters will affect the performance of the server, and we can save these parameters to the configuration file so that these parameters will automatically take effect each time the MySQL server is started. This configuration file is my. cnf. MySQL server provides MySQL optimization for the my. cnf file

Correct compilation methods are important, but they are only part of improving MySQL server performance. Many MySQL server parameters will affect the performance of the server, and we can save these parameters to the configuration file so that these parameters will automatically take effect each time the MySQL server is started. This configuration file is my. cnf.

MySQL server provides my. several examples of the cnf file can be found under the/usr/local/mysql/share/mysql/directory named my-small.cnf, my-medium.cnf, my-large.cnf, and my-huge.cnf, respectively. The scale description in the file name describes the applicable system types of the configuration file. For example, if the system memory that runs the MySQL server is small and MySQL is used only occasionally, the my-small.cnf configuration file is ideal, which tells mysqld daemon to use the least amount of system resources. Otherwise, if the MySQL server is used to support a large-scale online store, the system has 2 GB of memory, then the most appropriate use of mysql-huge.cnf.

To use the preceding sample configuration file, we should first copy the most suitable configuration file and name it my. cnf. The copied configuration file can be used in the following three ways:

Global: Copy the my. cnf file to the/etc directory of the server. the parameters defined in the file are globally valid, that is, they are valid for all MySQL database servers running on the server.
Local: copying this my. cnf file to [MYSQL-INSTALL-DIR]/var/will make the file valid only for the specified server, where [MYSQL-INSTALL-DIR] indicates the directory for installing MySQL.
User: At last, we can limit the scope of the file to a specified user, so we only need to copy the my. cnf file to the user's root directory.
So, how to set parameters in the my. cnf file? Or further, which parameters can be set? All these parameters have a global impact on the MySQL server, but each parameter is closely related to a specific part of MySQL. For example, the max_connections parameter belongs to the mysqld class. So how can we know this? Run the following command:


%>/Usr/local/mysql/libexec/mysqld -- help




This command displays various options and parameters related to mysqld. It is very convenient to search for these parameters because they are all following the content of the "Possible variables for option -- set-variable (-O) are" line. After finding these parameters, we can set all these parameters in the my. cnf file as follows:


Set-variable = max_connections = 100




The result of this line of code is that the maximum number of connections to the MySQL server at the same time is 100. Do not forget to add a set-variable command in the [mysqld] section of the my. cnf file. for details, see the example in the configuration file.

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.