Configuratiebestanden (MySQL): verschil tussen versies

Uit De Vliegende Brigade
Naar navigatie springen Naar zoeken springen
Regel 145: Regel 145:
 
#
 
#
 
max_allowed_packet=536870912
 
max_allowed_packet=536870912
 +
  
 
# log_bin_trust_function_creators
 
# log_bin_trust_function_creators

Versie van 5 jul 2020 16:26

In MySQL kun je instellingen configureren per gebruiker, of per systeem. Beiden worden in dit artikel behandeld.

Let op: MySQL is nogal kritisch als het om wijzigingen gaat. Daarom maak ik soms een backup voor ik iets om zeep help. Als het om MySQL-configuratiebestanden gaat, voeg ik een extensie aan het eind toe. Bv. my.cnf.bk01.

.my.cnf

.my.cnf is het configuratiebestand met gebruiker-specifieke instellingen. Dit bestand staat doorgaans direct in je home dir. 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

Systeembrede instellingen

Het kan verwarrend zijn waar je systeembrede instellingen moet toepassen, maar ingewikkelder dan dit hoeft 't niet te zijn:

cd /etc/mysql
sudo mv my.cnf my.cnf.bk-org
sudo cp mysql.cnf my.cnf
sudo vim my.cnf
  • Gebruik vervolgens bestand my.cnf voor eigen instellingen
  • Default-instellingen vind je in /etc/mysql/mysql.conf.d/mysql.cnf - Handig om dingen af te kijken
  • Na aanpassingen moet je de server herstarten, bv. met sudo service mysql restart (niet mysqld)

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 = ""

gevolgd door

sudo service mysql restart

Het resultaat:

mysql> show variables like "secure_file_priv";
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| secure_file_priv |       |
+------------------+-------+
1 row in set (0,00 sec)

Mijn /etc/mysql/my.cnf (zomer 2020)

De configuratie op m'n laptop. my.cnf.fallback is een werkende backup. my.cnf is het actuele bestand, en dat vind je hiernaast in detail

Complete bestand:

###########################################################################
# 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


# log_bin_trust_function_creators
###################################
#
# https://stackoverflow.com/questions/26015160/deterministic-no-sql-or-reads-sql-data-in-its-declaration-and-binary-logging-i
#
log_bin_trust_function_creators = 1;

###########################################################################
# 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

Zie ook