How to set global innodb_buffer_pool_size?

前端 未结 5 685

How to set the global innodb_buffer_pool_size mySQL variable? When I set it to system display I get this error:

ERROR 1238 (HY000):         


        
相关标签:
5条回答
  • 2021-01-01 21:47

    innodb_buffer_pool_size

    You should set this variable value under [mysqld] section as :

    innodb_buffer_pool_size=2G
    

    and restart MySQL service to have effect.

    InnoDB buffer pool caches both data and index pages. You can set this value to 70-80% of available memory for Innodb-only installations

    0 讨论(0)
  • 2021-01-01 21:48

    Look here innodb_buffer_pool_size documentation

    In there it says this variable can be set in option-file (my.cnf) or on the command line when starting the server.

    Also. I don't think you'll be able to assign the value of "system display" to this variable as it is a numeric. See the docs.

    0 讨论(0)
  • 2021-01-01 22:03

    I faced that same problem:

    ERROR 1238 (HY000): Variable 'innodb_buffer_pool_size' is a read only variable

    Then I notice I wrote [mysqly] wrongly at the top, and that's why my.cnf was not working properly. I change it to [mysqld] and restart MySQL, then everything is working perfectly.

    0 讨论(0)
  • 2021-01-01 22:06

    In the earlier versions of MySQL ( < 5.7.5 ) the only way to set

    'innodb_buffer_pool_size'

    variable was by writing it to my.cnf (for linux) and my.ini (for windows) under [mysqld] section :

    [mysqld]
    
    innodb_buffer_pool_size = 2147483648
    

    You need to restart your mysql server to have it's effect in action.

    UPDATE :

    As of MySQL 5.7.5, the innodb_buffer_pool_size configuration option can be set dynamically using a SET statement, allowing you to resize the buffer pool without restarting the server. For example:

    mysql> SET GLOBAL innodb_buffer_pool_size=402653184;
    

    Reference : http://dev.mysql.com/doc/refman/5.7/en/innodb-buffer-pool-online-resize.html

    Note

    Buffer pool size must always be equal to or a multiple of innodb_buffer_pool_chunk_size * innodb_buffer_pool_instances. If you configure innodb_buffer_pool_size to a value that is not equal to or a multiple of innodb_buffer_pool_chunk_size * innodb_buffer_pool_instances, buffer pool size is automatically adjusted to a value that is equal to or a multiple of innodb_buffer_pool_chunk_size * innodb_buffer_pool_instances that is not less than the specified buffer pool

    By @FlyingAtom

    0 讨论(0)
  • 2021-01-01 22:10

    You could do something like this from mysql command line / mysql workbench

    SET GLOBAL innodb_buffer_pool_size= (SELECT @@innodb_buffer_pool_size)*10
    #check via this:
    #SELECT @@innodb_buffer_pool_size/1024/1024/1024
    
    0 讨论(0)
提交回复
热议问题