Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
How to set memory limit in my.cnf file. I tried with memory_limit = 64M . But its showing error while restarting MYSQL server. Any one please help...
my.cnf
[mysqld]
datadir=/home/mysql/
tmpdir=/home/mysqltmp
#max_connections = 175 #was 175
max_connections = 80
#max_connect_errors = 350 #was 250
max_connect_errors = 250
safe-show-database
skip-locking
key_buffer = 1024M # was 128M
max_allowed_packet = 6M
myisam_sort_buffer_size = 64M
#old settings, for 900 ish max maxconn
#sort_buffer_size = 32M
#read_buffer_size = 32M
#read_rnd_buffer_size = 32M
sort_buffer_size = 5M
read_buffer_size = 5M
read_rnd_buffer_size = 5M
query_cache_size= 1024M
query_cache_limit= 16M
max_heap_table_size = 128M
tmp_table_size = 128M
thread_concurrency = 16
wait_timeout = 10
innodb_file_per_table
innodb_log_file_size = 10485760
open_files_limit = 8192
low_priority_updates = 1
#log_slow_queries = /var/log/mysql_slow.log
#log_queries_not_using_indexes = 1
#slow_queries_log_file = /var/log/mysql_slow.log
memory_limit = 64M
# who set these? these are NOT memory settings, but rather integer settings.
#table_cache = 1024M
#thread_cache_size = 8M
table_cache = 512
thread_cache_size = 8
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
[isamchk]
key_buffer = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M
[myisamchk]
key_buffer = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M
There is no such variables like memory_limit in MySQL my.cnf file. You can add variables only from MySQL server system variables. Read this How Mysql uses memory
It depends on RAM size of your MySQL server. You can configure your my.cnf file accordingly based on following basic formula for MySQL memory requirement calculation:
key_buffer_size + (read_buffer_size + sort_buffer_size) * max_connections = K bytes of memory
you may need to configure these basic parameters.
Sample variables from my.cnf file:
#MyISAM
key_buffer_size = 8G
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 2M
myisam_sort_buffer_size = 2M
join_buffer_size = 2M
#Innodb
innodb_buffer_pool_size = 16G
innodb_additional_mem_pool_size = 2G
innodb_log_file_size = 1G
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 30
innodb_file_format=barracuda
There is no memory_limit limit setting in MySQL. The only way you can manage or limit the memory usage of MySQL is to lower the settings for cache, buffer and pool sizes(the exact settingnames depend on what storage engine you are using.
Some settings that apply for the MyISAM engine (the default engine) is:
table_cache=1024
record_buffer=1M
sort_buffer_size=2M
read_buffer_size=2M
read_rnd_buffer_size=2M
myisam_sort_buffer_size=64M
thread_cache_size=128
query_cache_limit=1M
query_cache_size=64M
query_cache_type=1
For InnoDB you have:
innodb_buffer_pool_size = 256M
innodb_additional_mem_pool_size = 20M
innodb_log_file_size = 64M
innodb_log_buffer_size = 8M
If you are looking to change the memory limit in PHP that line(memory_limit = 64M) should be in the php.ini file, not my.cnf which is the configuration file for MySQL.
Related
This question already has an answer here:
Does PHP7's PDO ext read the entire result set into memory?
(1 answer)
Closed 3 years ago.
I couldn't find an answer online so I try my luck to ask here.
How to increase MySQL buffered query memory limit?
I try to execute a PDO query using PHP, but it bugged with error Out of memory (allocated 1444937728). After search for a while, it has nothing to do with PHP but with MySQL limits.
Although changing mysql config is still ineffective to solve the error. Here is my config
[mysqld]
port = 3306
socket = C:/neard/tmp/mariadb.sock
key_buffer_size = 64M
max_allowed_packet = 64M
bulk_insert_buffer_size = 2048M
table_open_cache = 1000
sort_buffer_size = 64M
read_buffer_size = 64M
read_rnd_buffer_size = 64M
innodb_sort_buffer_size = 32M
myisam_sort_buffer_size = 32M
basedir=C:/neard/bin/mariadb/mariadb10.3.8
log-error=C:/neard/logs/mariadb.log
datadir=C:/neard/bin/mariadb/mariadb10.3.8/data
long_query_time=3
slow_query_log_file=C:/neard/logs/slow_query.log
skip-external-locking
server-id = 1
innodb_buffer_pool_size = 128M
innodb_log_file_size = 5M
innodb_log_buffer_size = 8M
Clearly this number 1444937728 is defined or calculate somewhere, but I counln't find a doc about this.
Note: Most of the table engine is MyISAM
Change the setting in php.ini.
Section: sqlsrv
Directive: sqlsrv.ClientBufferMaxKBSize.
client_buffer_max_kb_size = '50240'
sqlsrv.ClientBufferMaxKBSize = 50240
I want to have some changes in my.ini as.... instead of making changes in my.ini located in mysql/bin....can I make my own my.ini for my php project.. such as
skip-external-locking
key_buffer = 384M
max_allowed_packet = 64M
table_open_cache = 4096
sort_buffer_size = 2M
#InnoDB specifications
innodb_buffer_pool_size = 384M
innodb_additional_mem_pool_size = 20M
innodb_log_file_size = 10M
innodb_log_buffer_size = 64M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 180
Use the ini_set function to change your php ini values without editing php.ini file.
Reffer this link : http://php.net/manual/en/function.ini-set.php
I'm running a Magento website with 100 visitor/hour and have 64GB RAM with an Intel Core i7 CPU. When I run mysqltuner, I receive the message "MySQL's maximum memory usage is dangerously high".
I need help with tuning MySQL to fit my needs, and to clear the warning.
Here is my.cnf file :
key_buffer = 32M
max_allowed_packet = 16M
thread_stack = 256K
thread_cache_size = 100
table_open_cache = 4000
table_definition_cache = 8192
tmp_table_size = 512M
max_heap_table_size = 512M
innodb_buffer_pool_instances = 24
innodb_flush_log_at_trx_commit = 0
innodb_read_io_threads = 64
innodb_write_io_threads = 64
innodb_io_capacity = 50000
innodb_flush_method = O_DIRECT
innodb_file_per_table
innodb_additional_mem_pool_size = 16M
transaction-isolation = READ-COMMITTED
innodb_support_xa = 0
innodb_commit_concurrency = 8
innodb_old_blocks_time = 1000
innodb_lock_wait_timeout = 120
innodb_buffer_pool_size = 40G
thread_concurrency = 10
max_connections = 64
innodb_thread_concurrency = 18
thread_cache_size = 64
table_cache = 2000
query_cache_type = 1
query_cache_size = 128M
query_cache_limit = 3M
key_buffer_size = 8G
sort_buffer_size = 64M
read_buffer_size = 64M
read_rnd_buffer_size = 64M
join_buffer_size = 128M
What can I do to make the mysqltuner warning disappear?
Suggestions to consider for your my.cnf-ini [mysqld] section
Lead with # the following or REMOVE them will allow MySQL defaults
to be used and go a long way toward eliminating the message.
sort_buffer_size = 64M
read_buffer_size = 64M
read_rnd_buffer_size = 64M
join_buffer_size = 128M
You will find response time is much better.
Please post complete TEXT of MySQL Tuner report.
Additional suggestions Jul 14, 2018
innodb_buffer_pool_instances=8 # from 24 minimize overhead
innodb_lru_scan_depth=128 # from 1024 to conserve CPU every second
For additional assistance, check my profile, clk Network Profile for contact info. Thanks
I have a project that uses 5 different data bases(oracle, mssql, ibm Informix , etc, ... and ...mysql)
Every timeout cron imports data into MySQL. Unfortunatelly we have one very huge cron script, that imports nearly 400 k rows. I made it to import data by small packs, but still, when cron runs this script, MySQL takes nearly 2 GB og memory, and wait for next call. Than takes 2 GB more, and this repeats before MySQL crashes.
We have already faced to the problem that MySQL innodb was corrupted and ran recovery mode from 1 to 4 to restart data base several times.
Total server virt memory is 12 GB.
Our configuration of /etc/my.cnf.d/ server.cnf looks like this:
#
# These groups are read by MariaDB server.
# Use it for options that only the server (but not clients) should see
#
# See the examples of server my.cnf files in /usr/share/mysql/
#
# this is read by the standalone daemon and embedded servers
[server]
# this is only for the mysqld standalone daemon
[mysqld]
default_storage_engine=innodb
character-set-server=utf8
back_log = 50
max_connections = 100
max_connect_errors = 10
table_open_cache = 2048
max_allowed_packet = 64M
binlog_cache_size = 16M
max_heap_table_size = 1G
read_buffer_size = 8M
read_rnd_buffer_size = 16M
sort_buffer_size = 8M
join_buffer_size = 8M
thread_cache_size = 32
# You should try [number of CPUs]*(2..4) for thread_concurrency
thread_concurrency = 8
query_cache_size = 64M
query_cache_limit = 1M
tmp_table_size = 1G
thread_stack = 240K
transaction_isolation = REPEATABLE-READ
ft_min_word_len = 4
log-bin=mysql-bin
binlog_format=mixed
#slow_query_log
#long_query_time = 10
group_concat_max_len = 10000
#*** MyISAM Specific options
key_buffer_size = 16M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 64M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
myisam_recover
# *** INNODB Specific options ***
innodb_file_per_table
innodb_buffer_pool_size=8G
#innodb_data_file_path = ibdata1:10M:autoextend
innodb_write_io_threads = 8
innodb_read_io_threads = 8
innodb_thread_concurrency = 16
innodb_flush_log_at_trx_commit = 1
innodb_log_buffer_size = 8M
innodb_log_file_size = 512M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
expire_logs_days=5
[mysqldump]
# Do not buffer the whole result set in memory before writing it to
# file. Required for dumping very large tables
quick
max_allowed_packet = 256M
[mysql]
no-auto-rehash
# Only allow UPDATEs and DELETEs that use keys.
safe-updates
[myisamchk]
key_buffer_size = 512M
sort_buffer_size = 512M
read_buffer = 8M
write_buffer = 8M
[mysqlhotcopy]
interactive-timeout
[mysqld_safe]
# Increase the amount of open files allowed per process. Warning: Make
# sure you have set the global system limit high enough! The high value
# is required for a large number of opened tables
open-files-limit = 8192
If any info is necessary to find out why this happens I will provide it.
Please! help me to find out the solution ! Should I reinstall MySQL, or it is still possible to resolve by config modifications???
I have both error in the title when I'm trying to upload a file bigger then about 3 megabytes to my server.
Here is what I tried in my.ini:
# The MySQL server
[wampmysqld]
SET SESSION wait_timeout=28800
SET GLOBAL wait_timeout=28800
interactive_timeout=3000
wait_timeout=3000
mysql.connect_timeout = 1000
port = 3306
socket = /tmp/mysql.sock
key_buffer_size = 16M
max_allowed_packet = 100M
sort_buffer_size = 8K
net_buffer_length = 512K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
basedir=c:/wamp/bin/mysql/mysql5.6.17
log-error=c:/wamp/logs/mysql.log
datadir=c:/wamp/bin/mysql/mysql5.6.17/data
[mysqld]
SET SESSION wait_timeout=28800
SET GLOBAL wait_timeout=28800
max_allowed_packet = 100M
interactive_timeout=3000
wait_timeout=3000
port=3306
explicit_defaults_for_timestamp = TRUE
and in php.ini:
; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
upload_max_filesize = 500M
The table containing the file has longblob data type for the content. I still have these errors after these changes. What should I do?