Everyone attaches great importance to MySQL environment variables. Similarly, the configuration of MySQL environment variables is also the focus of our attention. Next we will introduce you to some MySQL environment variable configuration knowledge.
Modify MySQL running parameters and/etc/my. the cnf file adjusts the mysql running parameters and takes effect after MySQL is restarted. After MySQL 4, some internal variables can be set during MySQL running, but the restart of mysql becomes invalid.
Mysqld Program-directory and file
Basedir = path # Use the given directory as the root directory (installation directory ).
Datadir = path # Read database files from a given directory.
Pid-file = filename # specify a file for the mysqld program to store the process ID (only applicable to UNIX/Linux systems );
[Mysqld]
Socket =/tmp/mysql. sock # specifies a socket file for local communication between the MySQL client program and the server (/var/lib/mysql. sock file by default in Linux)
Port = 3306 # specify the port on which MsSQL listens
Key_buffer = 384 M # key_buffer is the buffer size used for index blocks. You can add indexes that can be better processed (for all reads and multiple writes ).
The index block is buffered and shared by all threads. The size of key_buffer depends on the memory size.
Table_cache = 512 # number of tables opened for all threads. Increase this value to increase the number of file descriptors required by mysqld. Avoid overhead caused by frequent data table opening.
Sort_buffer_size = 2 M # Each thread that needs to be sorted allocates a buffer of this size. Add this value to accelerate the order by or group by operation.
Note: The allocated memory corresponding to this parameter is exclusive to each connection! If there are 100 connections, the total size of the actually allocated sort buffer is 100 × 6 = 600 MB.
Read_buffer_size = 2 M # buffer size available for read query operations. Like sort_buffer_size, the allocated memory corresponding to this parameter is also exclusive to each connection.
Query_cache_size = 32 M # specify the buffer size of MySQL query results
Read_rnd_buffer_size = 8 M # this parameter is used for random read after the row pointer is used for sorting.
Myisam_sort_buffer_size = 64 M # buffer required for sorting the MyISAM table again when it changes
Thread_concurrency = 8 # maximum number of concurrent threads. The value is the number of logical CPUs on the server × 2. If the CPU supports H.T hyper-threading, then × 2
Thread_cache = 8 # Number of reusable cache threads
Skip-locking # Avoid MySQL external locks, reduce the chance of errors, and enhance stability.
[Mysqldump]
Max_allowed_packet = 16 M # maximum possible information packages that can be sent between the server and the client
[Myisamchk]
Key_buffer = 256 M
Sort_buffer = 256 M
Read_buffer = 2 M
Write_buffer = 2 M
The above is the MySQL environment variable configuration instructions.
Example of creating a MySQL Stored Procedure
Use of mysql ifnull Functions
MySQL date functions
Provides you with an in-depth understanding of the MYSQL Cast function.
Learn more about mysql CONCAT () Functions