2 Mayıs 2022 Pazartesi

/etc/mysql/my.cnf Dosyası - MySQL Veri Tabanı Sunucu Ayaları Dosyası

Giriş
Bu dosya mysqld Daemon tarafından kullanılır. 

Bazı Açıklamalar
- Linux ve türevi işletim sistemlerinde bu dosyanın ismi my.cnf.  Dizin olarak /etc/mysql/ veya sadece /etc/ kullanılır. Window işletim siteminde bu dosyanın ismi my.ini
Açıklaması şöyle
The MySQL configuration file is located in the /var/lib/mysql/ directory on Linux and inside of the MySQL version folder on Windows, and it's called either my.cnf or my.ini, respectively. The contents of the file are pretty much the same on both operating systems, though there are slightly more comments on the Windows version of the file.
- Eğer bu dosyayı değiştirmek istemiyorsak MySQL komutu satırı seçenekleri kullanılabilir. 
Örnek
Şöyle yaparız
mysql --host=localhost --user=root --password=mypassword --database=mydatabase \
  --innodb_print_all_deadlocks=0
- Eğer bu dosyayı değiştirmek istemiyorsak ve geçici olarak bir şey denemek istiyorsak SET GLOBAL kullanılabilir
Örnek
Şöyle yaparız
mysql> SET GLOBAL innodb_print_all_deadlocks = 1;
Ayarların açıklaması
Bu dosyadaki ayarların açıklaması şöyle
The file contains every setting that is displayed by the daemon, ranging from settings relevant to the MySQL client itself to SQL modes. All of these options can be also set at runtime by using parameters beginning by "--": we can make MySQL run in an ANSI mode by specifying mysqld --ansi, we can specify the amount of I/O threads available for use by specifying their number (#) in mysqld --innodb-write-io-threads=#, etc.

The configuration works this way because it contains the parameters (sometimes also called variables) which then interact with the daemon, and consequently alter how the daemon (MySQL) functions as a whole.
Diğer Dosyalar
Bu dosya başka konfigürasyon dosyalarını kullanabilir. Mesela "/etc/mysql/mysql.conf.d/mysqld.cnf" Bir açıklama burada

connect_timeout Değişkeni
Şöyle yaparız
connect_timeout=10
binlog_expire_logs_seconds Değişkeni
MySQL Binary Logs yazısına bakabilirsiniz. Burada binlog_expire_logs_seconds ile logların kaç saniye sonra silieneceği belirtiliyor.

Örnek
Şöyle yaparız
[mysqld]
log_bin =                           # turn off
binlog_expire_logs_seconds = 86400  # 1 day
max_binlog_size = 104857600         # 100M
Aynı şeyi şöyle yaparız
mysql> SET GLOBAL binlog_expire_logs_seconds = (60*60*24*3);
Query OK, 0 rows affected (0.00 sec)

mysql> SET PERSIST binlog_expire_logs_seconds = (60*60*24*3);
Query OK, 0 rows affected (0.01 sec)
binlog_format Değişkeni
3 formattan birisi kullanılıyor
1. Statement-Based Logging
2. Row-Based Logging
3. Mixed Logging
Örnek
Şöyle yaparız. binlog_format alanı statement, row ve mixed değerlerini alabilir.
log-bin=mysql-bin
expire_logs_days = 2
binlog_format=mixed # Recommended binary logging format – mixed
innodb_buffer_pool_size Değişkeni
Açıklaması şöyle
Pro tip: If you are setting a PostgreSQL or MySQL, don't use the default database settings because those are meant for personal computers or notebooks.

One example is the Buffer Pool size:

- For MySQL, increase the innodb_buffer_pool_size
- For PostgreSQL, increase shared_buffers and effective_cache_size to match your OS cache size
Ör
innodb_print_all_deadlocks Değişkeni
Açıklaması şöyle
In MySQL, the system automatically detects deadlocks in InnoDB (the default storage engine) and resolves them by rolling back a transaction. The details of the deadlock can be found in the error log if the innodb_print_all_deadlocks configuration is set to ON.
lower_case_table_names Değişkeni
MySQL Linux'ta çalıştığı için tablo isimlerinin büyük küçük harf duyarlı olduğunu gördüm
Bunu değiştirmek için  şöyle yaparız
lower_case_table_names = 1
secure_file_priv Değişkeni
Açıklaması şöyle
One of the most popular parameters is the secure_file_priv variable. This parameter controls where MySQL is allowed to ingest data when the LOAD DATA INFILE statement is being used. The default value for MySQL on Windows is the tmp directory: secure_file_priv="c:/wamp64/tmp".

This variable is important because it puts a restraint on which directories can contain data that is eligible for inclusion in your MySQL database instance. If we load data into MySQL from the wrong directory, we will see a message outlining that we should choose a different folder: ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement.





Hiç yorum yok:

Yorum Gönder

Soft Delete

Giriş Açıklaması  şöyle When using the soft delete mechanism on the database, you might run into a situation where a record with a unique co...