Debian 7.0 x86 minimal;默认的MySQL 5.5。

再来个MySQL配置文件my.cnf,让MySQL内存占用能控制在32MB-64MB之间,以便能安装其他例如Nginx等应用。

128MB内存的VPS运行MySQL,Nginx,PHP不是难事,lowendbox.com博主在多年前有写过64MB内存VPS上运行WordPress的文章,128MB内存都翻倍了,显然更无压力。

my.cnf

my-medium.cnf,下面的MySQL配置文件,如果还需要安装其他软件包,适合在128MB内存的VPS上,64MB内存上的话还需要小小修改一下。

# Example MySQL config file for medium systems.
#
# This is for a system with little memory (32M - 64M) where MySQL plays
# an important part, or systems up to 128M where MySQL is used together with
# other programs (such as a web server)
#
# MySQL programs look for option files in a set of
# locations which depend on the deployment platform.
# You can copy this option file to one of those
# locations. For information about these locations, see:
# http://dev.mysql.com/doc/mysql/en/option-files.html
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.

# The following options will be passed to all MySQL clients
[client]
port        = 3306
socket        = /var/run/mysqld/mysqld.sock

[mysqld_safe]
socket      = /var/run/mysqld/mysqld.sock
nice        = 0

# The MySQL server
[mysqld]
user            = mysql
port            = 3306
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
basedir         = /usr
datadir         = /var/lib/mysql
tmpdir          = /tmp
lc-messages-dir = /usr/share/mysql

skip-external-locking
key_buffer_size         = 16M
max_allowed_packet      = 1M
table_open_cache        = 64
sort_buffer_size        = 512K
net_buffer_length       = 8K
read_buffer_size        = 256K
read_rnd_buffer_size    = 512K
myisam_sort_buffer_size = 8M

#if no other servers are going to be connecting to this server, uncomment the following line
#bind-address            = 127.0.0.1 

skip-innodb
default-storage-engine = MyISAM

max-connections = 25

query-cache-size  = 2M
query-cache-limit = 1M

thread-stack      = 256K
thread-cache-size = 2M

slow-query-log
long_query_time   = 5

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash

[myisamchk]
key_buffer_size  = 20M
sort_buffer_size = 20M
read_buffer      = 2M
write_buffer     = 2M

[mysqlhotcopy]
interactive-timeout

命令:

apt-get install -y mysql-server
mv /etc/mysql/my.cnf /etc/mysql/my.cnf.backup
nano /etc/mysql/my.cnf //拷贝上面的配置文件
/etc/init.d/mysql restart

这个配置文件下载my-medium.cnf

curl -o /etc/mysql/my.cnf https://onebox.site/usr/uploads/2017/08/1163362389.cnf