A netizen's experience in MySQL database Optimization

Source: Internet
Author: User

We know thatMySQL database OptimizationThere are many methods on the Internet. This article mainly introduces the optimization experience of a MySQL database user, hoping to help you.

Optimization experience:

Run the show variables command to view the variable value of max_connections for the maximum number of connections in the database.

Run the command: show status; to view the currently active connection thread variable value: threads_connected.

Set the new maximum number of connections to 2000: mysql> set GLOBAL max_connections = 2000;

The maximum number of connections allowed by the actual MySQL server is 16384; the value of tmp_table_size is the default 32 M, and the value of tmp_table_size is changed to 200 M:

Tmp_table_size = 33554432; // The default unit is byte.

Mysql> set tmp_table_size = 209715200; these seem to work temporarily! I am using xampp so to D: \ xampp \ mysql \ bin

Although I have a my. ini file in C: \ windows, I found that the parameter was changed. It seems that I didn't work. Finally, I found that using editplus to open my here is easy to use!

 
 
  1. [Mysqld]
  2. Port = 3306
  3. Socket = "D:/xampp/mysql. sock"
  4. Basedir = "D:/xampp/mysql"
  5. Tmpdir = "D:/xampp/tmp"
  6. Datadir = "D:/xampp/mysql/data"
  7. Skip-locking
  8. Key_buffer = 16 M
  9. Max_allowed_packet = 1 M
  10. Table_cache = 64
  11. Sort_buffer_size = 512 K
  12. Net_buffer_length = 8 K
  13. Read_buffer_size = 256 K
  14. Read_rnd_buffer_size = 512 K
  15. Myisam_sort_buffer_size = 8 M
  16. Max_connections = 2000
  17. Tmp_table_size = 209715200
  18. Long_query_time = 2
  19. # Enter a name for the query log file. Otherwise a default name will be used.
  20. # Note: writing the txt file editplus can be reloaded in time, but it can be reloaded only when it is stored on drive C)
  21. Log = c:/mysql_query.log.txt
  22. # Enter a name for the slow query log file. Otherwise a default name will be used.
  23. Log-slow-queries = c:/mysql_solw_query.log.txt
  24. # Enter a name for the update log file. Otherwise a default name will be used.
  25. Log-update = # Enter a name for the binary log. Otherwise a default name will be used.

Log-bin = MYSQL installed in windows does not contain mysqldumpslow, so the generated log files cannot be analyzed in windows. However, you can store the generated log files in MYSQL in LINUX for analysis. You can run the following command on the command line to enter the mysql/bin directory, test slowquery, the log file generated in windows. rename log to slowquery. log to the mysql/bin directory): mysqldumpslow slowquery. log to view the analysis content.

Here is an introduction to MySQL database optimization. I hope this introduction will be helpful to you!

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.