日期:2014-05-16  浏览次数:20723 次

第一节 MYSQL 参数配置
由于ORACLE价格昂贵。生产开发中开始转用mysql数据。在开发和学习中碰到了许多问题。在这里做下总结。

一 MYSQL 版本
目前有关4.X ,5.X,6.X
每个版本中又有Standdard,Max,Debug 三个类型
当然又分为windows平台下的和LINUX平台


二 配置文件夹

mysql的数据库的系统配置文件叫做my.ini
新下载的绿色版mysql或者安装后的mysql,在根目录下还有好几个后缀是ini的文件
例:my-huge.ini,my-innodb-heavy-4G.ini,my-large.ini,my-medium.ini,my-small.ini,my-template.ini
mysql启动后只会加载my.ini这个配置文件。用其他文件替换my.ini就会修改mysql启动参数。根据名称也可大体明白各ini文件表达的意思。可根据不同情况选用合适的ini启动文件。


三 配置说明

端口号
port=3306
字符集
default-character-set=gbk
安装MYSQL的根目录
basedir="D:/Program Files/MySQL/MySQL Server 5.0/"
数据库目录
datadir="D:/Program Files/MySQL/MySQL Server 5.0/Data/"
存储引荐,另外一个是mysql特有的,还经常用到的是myisam(不支持事务)
default-storage-engine=INNODB(唯一支持事务的引荐)

sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
最大链接数
max_connections=100


以下是配置参数的优化说明
# MySQL Server Instance Configuration File
# ----------------------------------
# Generated by the MySQL Server Instance Configuration Wizard
#
#
# Installation Instructions
# ----------------------------------
#
# On Linux you can copy this file to /etc/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options
# (@localstatedir@ for this installation) or to
# ~/.my.cnf to set user-specific options.
#
# On Windows you should keep this file in the installation directory
# of your server (e.g. C:\Program Files\MySQL\MySQL Server X.Y). To
# make sure the server reads the config file use the startup option
# "--defaults-file".
#
# To run run the server from the command line, execute this in a
# command line shell, e.g.
# mysqld --defaults-file="C:\Program Files\MySQL\MySQL Server X.Y\my.ini"
#
# To install the server as a Windows service manually, execute this in a
# command line shell, e.g.
# mysqld --install MySQLXY --defaults-file="C:\Program Files\MySQL\MySQL Server X.Y\my.ini"
#
# And then execute this in a command line shell to start the server, e.g.
# net start MySQLXY
#
#
# Guildlines for editing this file
# ----------------------------------
#
# In this file, you can use all long options that the program supports.
# If you want to know the options a program supports, start the program
# with the "--help" option.
#
# More detailed information about the individual options can also be
# found in the manual.
#
#
# CLIENT SECTION
# ----------------------------------
#
# The following options will be read by MySQL client applications.
# Note that only client applications shipped by MySQL are guaranteed
# to read this section. If you want your own MySQL client program to
# honor these values, you need to specify it as an option during the
# MySQL client library initialization.
#
[client]

port=3306

[mysql]

default-character-set=gbk


# SERVER SECTION
# ----------------------------------
#
# The following options will be read by the MySQL Server. Make sure that
# you have installed the server correctly (see above) so it reads this
# file.
#
[mysqld]

# The TCP/IP Port the MySQL Server will listen on
port=3306


#Path to installation directory. All paths are usually resolved relative to this.
basedir="D:/Program Files/MySQL/MySQL Server 5.0/"

#Path to the database root
datadir="D:/Program Files/MySQL/MySQL Server 5.0/Data/"

# The default character set that will be used when a new schema or table is
# created and no character set is defined
default-character-set=gbk

# The default storage engine that will be used when create new