Configuratiebestanden (MySQL): verschil tussen versies
Regel 134: | Regel 134: | ||
+------------------+-------+ | +------------------+-------+ | ||
1 row in set (0,00 sec) | 1 row in set (0,00 sec) | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</pre> | </pre> | ||
Versie van 29 mei 2020 14:29
Altijd verwarrend waar je systeeminstellingen van MySQL aanpast. Daarnaast is MySQL nogal kritisch als het om wijzigingen gaat. Er zijn twee soorten bestanden: Systeem-wijde instellingen in /etc en gebruiker-specifieke instellingen in ~/. Dit artikel gaat vooral over deze eerste.
Spoorzoeken
Er is een verwarrend woud aan placeholder-configuratiebestanden, die ook nog 's allemaal naar elkaar lijken te verwijzen:
System-wide
* /etc/mysql/ * debian.cnf * debian-start * my.cnf → /etc/alternatives/my.cnf → /etc/mysql/mysql.cnf (echt waar!) * my.cnf.fallback * mysql.cnf * mysql.conf.d/ * mysqld.cnf * mysqld_safe_syslog.cnf
Maar daar houdt het niet op, want dit is de inhoud van de 'placeholder' files hierboven:
!includedir /etc/mysql/conf.d/ !includedir /etc/mysql/mysql.conf.d/
User-specific
In je home dit heb je een bestand .my.cnf
.
Niet meer spoorzoeken
Voor systeem-brede aanpassingen:
cd /etc/mysql sudo mv my.cnf my.cnf.oud sudo cp mysql.cnf my.cnf
Gebruik nu bestand my.cnf
voor eigen instellingen.
- Bron: Uitleg in bestand mysql.cnf
- Verder vind je default-instellingen in
/etc/mysql/mysql.conf.d/mysql.cnf
- Handig om dingen af te kijken.
.my.cnf
In je home dir staat doorgaans een bestand .my.cnf
. Mijn versie (licht bijgewerkt, april 2020):
################################################################################################ # [Client] ################################################################################################ # [client] host = localhost socket = /var/run/mysqld/mysqld.sock # Specifying user & password to avoid authentication #################################################### # user = supervrouw password = mijnwachtwoord # Include comments when importing sql-files #################################################### # comments = true ################################################################################################ # [mysqldump] ################################################################################################ # [mysqldump] # Include sprocs & functions when making dumps ############################################## # routines = true # Continue with dump despite errors in views ############################################## # force = true
Backups
Configuratiebestanden moeten welliswaar de extensie .cnf
hebben, maar niet alle bestanden met de extensie .cnf
worden automatisch uitgevoerd. Je kunt dus backups maken met namen zoals my.cnf.bk01
.
Voorbeeld: Aanpassen secure_file_priv
Vantevoren:
mysql> show variables like "secure_file_priv"; +------------------+----------------------------+ | Variable_name | Value | +------------------+----------------------------+ | secure_file_priv | /var/lib/mysql-files/ | +------------------+----------------------------+ 1 row in set (0,00 sec)
Ik heb bestand /etc/mysql/my.cnf
aangepast. Dit is nu het hele bestand:
!includedir /etc/mysql/conf.d/ !includedir /etc/mysql/mysql.conf.d/ ################################################## # HERE IS MY OWN STUFF - STROMPF ################################################## # [mysqld] secure-file-priv = ""
En het werkt:
mysql> show variables like "secure_file_priv"; +------------------+-------+ | Variable_name | Value | +------------------+-------+ | secure_file_priv | | +------------------+-------+ 1 row in set (0,00 sec)
Voorbeeld: Mijn /etc/mysql/my.cnf (zomer 2020)
Complete bestand:
# ########################################################################### # Defaults ########################################################################### # # This line is optional: Server will still start without this line # !includedir /etc/mysql/conf.d/ ########################################################################### # Strompf - [mysqld] ########################################################################### # [mysqld] # Remove I/O path restrictions ############################## # secure_file_priv="" # Enable longer concat string ############################# # group_concat_max_len = 300000 # Disable MySQL Strict Mode ########################### # sql_mode="" # Increase max_packet_size ########################### # max_allowed_packet=536870912 ########################################################################### # Strompf - [client] ########################################################################### # # Normally, starting the server takes about a second ("sudo service mysql # restart"). Withh these [client] & [mysqldump] sections, this takes about 5 # seconds. I still find it handy to put everyting in this one location, # especially when collaborating with others on projects # # [client] # Include comments when importing sql-files #################################################### # comments = true ########################################################################### # Strompf - [mysqldump] ########################################################################### # [mysqldump] # Include sprocs & functions when making dumps ############################################## # routines = true # Continue with dump despite errors in views ############################################## # force = true