mysql设置主题_主题:MySql配置(网易的)

Hompy项目现使用2台数据服务器,主从数据库内存分别为8G和6G。

开始老是down机,以my-huge为基础配了很多次,都不行,

后来,借用了mail.sanook.com的配置,撑了一断时间,还是不理想。

再借用网易(163.com)一个子项目的my.cnf试了一下,几个月没down,先用它撑一下。

注:网易使用的是2G内存的。

共享一下:

# Example MySQL config file for very large systems.

#

# This is for a large system with memory of 1G-2G where the system runs mainly

# MySQL.

#

# You can copy this file to

# /etc/my.cnf to set global options,

# mysql-data-dir/my.cnf to set server-specific options (in this

# installation this directory is /var/lib/mysql) or

# ~/.my.cnf to set user-specific options.

#

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

#password       = your_password

port            = 3306

socket          = /var/lib/mysql/mysql.sock

# Here follows entries for some specific programs

# The MySQL server

[mysqld]

port            = 3306

socket          = /var/lib/mysql/mysql.sock

skip-locking

skip-innodb

skip-bdb

#back_log=100

back_log=200

#key_buffer=500M

key_buffer=512M

#key_buffer = 384M

#max_allowed_packet = 2M

#max_allowed_packet = 1M

max_allowed_packet = 4M

#table_cache = 512

table_cache = 1024

#sort_buffer_size=32M

#sort_buffer_size = 2M

sort_buffer_size = 16M

#read_buffer_size = 8M

#read_buffer_size = 2M

read_buffer_size = 16M

#read_rnd_buffer_size = 16M

#read_rnd_buffer_size = 8M

read_rnd_buffer_size = 32M

#myisam_sort_buffer_size = 256M

myisam_sort_buffer_size = 64M

#thread_cache =80

thread_cache = 8

#query_cache_size = 64M

#query_cache_size = 32M

query_cache_size = 16M

log-slow-queries=/var/log/slowlog.log

long_query_time = 2

# Try number of CPU's*2 for thread_concurrency

thread_concurrency = 4

default-character-set=utf8

### mysql tuning

#set-variable = max_user_connections=600

set-variable = max_user_connections=1000

set-variable = max_connections=1000

#set-variable = table_cache=1200

#set-variable = max_allowed_packet=1M

#set-variable = max_connect_errors=999999

#set-variable = max_connect_errors=20

set-variable = max_connect_errors=1000

set-variable = wait_timeout=10

#set-variable = interactive_timeout=300

set-variable = interactive_timeout=120

#set-variable = tmp_table_size = 2M

#set-variable = join_buffer_size = 2M

###

# Don't listen on a TCP/IP port at all. This can be a security enhancement,

# if all processes that need to connect to mysqld run on the same host.

# All interaction with mysqld must be made via Unix sockets or named pipes.

# Note that using this option without enabling named pipes on Windows

# (via the "enable-named-pipe" option) will render mysqld useless!

#

#skip-networking

# Replication Master Server (default)

# binary logging is required for replication

# log-bin = /var/log/mysql/mysql-bin.log

# binlog-do-db = exampledb

# required unique id between 1 and 2^32 - 1

# defaults to 1 if master-host is not set

# but will not function as a master if omitted

server-id       = 1

# Replication Slave (comment out master section to use this)

#

# To configure this host as a replication slave, you can choose between

# two methods :

#

# 1) Use the CHANGE MASTER TO command (fully described in our manual) -

#    the syntax is:

#

#    CHANGE MASTER TO MASTER_HOST=, MASTER_PORT=,

#    MASTER_USER=, MASTER_PASSWORD= ;

#

#    where you replace , , by quoted strings and

#    by the master's port number (3306 by default).

#

#    Example:

#

#    CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,

#    MASTER_USER='joe', MASTER_PASSWORD='secret';

#

# OR

#

# 2) Set the variables below. However, in case you choose this method, then

#    start replication for the first time (even unsuccessfully, for example

#    if you mistyped the password in master-password and the slave fails to

#    connect), the slave will create a master.info file, and any later

#    change in this file to the variables' values below will be ignored and

#    overridden by the content of the master.info file, unless you shutdown

#    the slave server, delete master.info and restart the slaver server.

#    For that reason, you may want to leave the lines below untouched

#    (commented) and instead use CHANGE MASTER TO (see above)

#

# required unique id between 2 and 2^32 - 1

# (and different from the master)

# defaults to 2 if master-host is set

# but will not function as a slave if omitted

#server-id       = 2

#

# The replication master for this slave - required

#master-host     =  

#

# The username the slave will use for authentication when connecting

# to the master - required

#master-user     =  

#

# The password the slave will authenticate with when connecting to

# the master - required

#master-password =  

#

# The port the master is listening on.

# optional - defaults to 3306

#master-port     = 

#

# binary logging - not required for slaves, but recommended

log-bin

binlog-do-db = hompy_mweb

# Point the following paths to different dedicated disks

#tmpdir         = /tmp/

tmpdir         = /var/mysqltmp

#log-update     = /path-to-dedicated-directory/hostname

# Uncomment the following if you are using BDB tables

#bdb_cache_size = 384M

#bdb_max_lock = 100000

# Uncomment the following if you are using InnoDB tables

#innodb_data_home_dir = /var/lib/mysql/

#innodb_data_file_path = ibdata1:2000M;ibdata2:10M:autoextend

#innodb_log_group_home_dir = /var/lib/mysql/

#innodb_log_arch_dir = /var/lib/mysql/

# You can set .._buffer_pool_size up to 50 - 80 %

# of RAM but beware of setting memory usage too high

#innodb_buffer_pool_size = 384M

#innodb_additional_mem_pool_size = 20M

# Set .._log_file_size to 25 % of buffer pool size

#innodb_log_file_size = 100M

#innodb_log_buffer_size = 8M

#innodb_flush_log_at_trx_commit = 1

#innodb_lock_wait_timeout = 50

[mysqldump]

quick

max_allowed_packet = 16M

[mysql]

no-auto-rehash

# Remove the next comment character if you are not familiar with SQL

#safe-updates

default-character-set=utf8

[isamchk]

key_buffer = 256M

sort_buffer_size = 256M

read_buffer = 2M

write_buffer = 2M

[isamchk]

key_buffer = 256M

sort_buffer_size = 256M

read_buffer = 2M

write_buffer = 2M

[myisamchk]

key_buffer = 256M

sort_buffer_size = 256M

read_buffer = 2M

write_buffer = 2M

[mysqlhotcopy]

interactive-timeout

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: ‘caching_sha2_password’ 是 MySQL 8.0 版本引入的一种插件,用于增强对用户密码的加密保护。在连接数据库时,如果发生 [tc_mysql::connect]: mysql_real_connect: authentication plugin 'caching_sha2_password' 错误,可能是以下两个原因之一: 1. MySQL 8.0 版本之前的客户端与 MySQL 8.0 版本以上的服务器进行连接时,由于默认加密插件不匹配,导致认证失败。解决方法是升级客户端版本或为相应的用户更改默认的加密插件。 2. MySQL 8.0 版本以上的服务器设置了默认使用 'caching_sha2_password' 插件进行认证,但客户端版本较低,并不支持该插件。解决方法是在服务器端修改用户的加密插件为旧版本所支持的插件,如 'mysql_native_password'。 在解决该错误时,可以采取以下步骤: 1. 升级客户端版本,确保与服务器兼容。 2. 在服务器端,找到相应用户并修改其加密插件为旧版本所支持的插件。 3. 如果连接仍然失败,可以尝试更新客户端的 MySQL 驱动程序,或使用其他不同版本的驱动程序。 总的来说,[tc_mysql::connect]: mysql_real_connect: authentication plugin 'caching_sha2_password' 错误是由于客户端与服务器的加密插件不匹配所致,需要升级客户端版本或修改服务器端的用户加密插件来解决。 ### 回答2: 这个错误是由于MySQL数据库连接时使用了"authentication plugin 'caching_sha2_password'",但是相应的驱动程序不支持此插件所导致的。 为了解决这个问题,有以下几种方法: 1. 更新驱动程序:查找并下载最新版本的MySQL驱动程序。新版本的驱动程序通常会支持新的插件。安装更新的驱动程序后,再次尝试连接数据库。 2. 修改MySQL用户的身份验证插件:如果使用的是MySQL 5.7以上版本,可以尝试将用户的身份验证插件修改为旧的插件,例如'mysql_native_password'。这可以通过修改MySQL用户的身份验证插件选项以及刷新权限来完成。 3. 修改MySQL服务配置:在MySQL配置文件中,可以尝试禁用所有新的身份验证插件,只使用旧的插件。找到MySQL配置文件(通常位于/etc/mysql目录下),找到并编辑my.cnf或my.ini文件,在[mysqld]部分添加或修改一行如下配置:default_authentication_plugin = mysql_native_password。保存文件后,重启MySQL服务。 以上是解决"tc_mysql::connect: mysql_real_connect: authentication plugin 'caching_sha2_password'"错误的几种方法。根据具体情况选择合适的方法来解决问题。 ### 回答3: 认证插件 'caching_sha2_password' 导致 MySQL 连接错误的可能原因有以下几点。 首先,该错误可能是因为 MySQL 服务器使用了不同的身份验证插件,而 PHP 中的 MySQL 扩展不支持该插件。在较新版本的 MySQL 中,默认身份验证插件是 'caching_sha2_password',而较旧版本的 PHP MySQL 扩展只支持旧的身份验证插件。 解决这个问题的一种方法是升级 PHP 版本,或者使用支持新身份验证插件的第三方 MySQL 扩展库,例如 MySQLi 或 PDO。这些扩展库兼容较新版本的 MySQL,并能正确地处理 'caching_sha2_password' 插件。 另外,该错误也可能是由于 MySQL 服务器未正确配置所致。您可以检查 MySQL配置文件(通常是 my.cnf 或 my.ini)中的设置。确保在 [mysqld] 部分中,有一个正确的默认身份验证插件设置,如下所示: default_authentication_plugin = mysql_native_password 如果该行不存在,或者设置为其他非 'mysql_native_password' 插件,可尝试添加或修改该设置并重启 MySQL 服务器。 最后,如果您无权更改 MySQL 服务器的配置或升级 PHP 版本,同时又无法使用其他支持新身份验证插件的扩展库,您可以联系服务器管理员或开发者,以获取进一步的帮助和解决方案。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值