`
vincen_gao
  • 浏览: 4688 次
  • 性别: Icon_minigender_1
  • 来自: 西安
最近访客 更多访客>>
社区版块
存档分类
最新评论

MySQL免安装版配置与安装

 
阅读更多

step1:解压mysql包,我的路径是E:\mysql-5.5.19,就用%MySQL_HOME%表示。

step2:写my.ini文件,这个是mysql启动时的配置文件,压缩包里默认提供了几个配置模版,my-small.ini, my-medium.ini, my-large.ini, my-huge.ini, my-innodb-heavy-4G.ini。这几个模版的主要区别是和内存有关的。

如small模版就说:如果系统内存小于64M,并且mysql不常用使用,那就用这个模版,并且使用这个模版mysqld  daemon守护精灵占用的资源最少。这个基本上就是做嵌入式数据库啦。

如果数据库在你的开发中应用中扮演一个比较重要的角色,那就用medium模版。medium模版即适合32M-64M内存的系统使用,又可以满足web开发使用。(是它自己说的,看来这个是全能型选手)

large模版,如果你的系统内存有512M,并且主要运行mysql,那就用这个。(512M现在大家都能轻松达到吧~~)

huge模版,就是系统内存在1G-2G之间用的。

my-innodb-heavy-4G这个模版就厉害,系统4G内存,并且只使用innodb表。这个基本上就是单做数据库服务器才用的。

以下贴上我的my.ini配置:

 

# The following options will be passed to all MySQL clients
[client]
# set default character for client
default-character-set=utf8
#password	= your_password
port		= 3306
socket		= /tmp/mysql.sock

# Here follows entries for some specific programs

# The MySQL server
[mysqld]
# The default character set that will be used when a new schema or table is
# created and no character set is defined
character-set-server=utf8
#Path to installation directory. All paths are usually resolved relative to this.
basedir="E:/mysql-5.5.19/"
#Path to the database root
datadir="E:/mysql-5.5.19/data/"
# The default storage engine that will be used when create new tables when
default-storage-engine=INNODB
# Set the SQL mode to strict
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
# The maximum amount of concurrent sessions the MySQL server will
# allow. One of these connections will be reserved for a user with
# SUPER privileges to allow the administrator to login even if the
# connection limit has been reached.
max_connections=50
# Query cache is used to cache SELECT results and later return them
# without actual executing the same query once again. Having the query
# cache enabled may result in significant speed improvements, if your
# have a lot of identical queries and rarely changing tables. See the
# "Qcache_lowmem_prunes" status variable to check if the current value
# is high enough for your load.
# Note: In case your tables change very often or if your queries are
# textually different every time, the query cache may result in a
# slowdown instead of a performance improvement.
query_cache_size=67108864
# The number of open tables for all threads. Increasing this value
# increases the number of file descriptors that mysqld requires.
# Therefore you have to make sure to set the amount of open files
# allowed to at least 4096 in the variable "open-files-limit" in
# section [mysqld_safe]
table_cache=256
# Maximum size for internal (in-memory) temporary tables. If a table
# grows larger than this value, it is automatically converted to disk
# based table This limitation is for a single table. There can be many
# of them.
tmp_table_size=9M
# How many threads we should keep in a cache for reuse. When a client
# disconnects, the client's threads are put in the cache if there aren't
# more than thread_cache_size threads from before.  This greatly reduces
# the amount of thread creations needed if you have a lot of new
# connections. (Normally this doesn't give a notable performance
# improvement if you have a good thread implementation.)
thread_cache_size=16

port		= 3306
socket		= /tmp/mysql.sock
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

# Replication Master Server (default)
# binary logging is required for replication
log-bin=mysql-bin

# binary logging format - mixed recommended
binlog_format=mixed

# 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

# Uncomment the following if you are using InnoDB tables
innodb_data_home_dir ="E:/mysql-5.5.19/data/"
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir ="E:/mysql-5.5.19/data/"
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
innodb_buffer_pool_size = 64M
# Additional memory pool that is used by InnoDB to store metadata
# information.  If InnoDB requires more memory for this purpose it will
# start to allocate it from the OS.  As this is fast enough on most
# recent operating systems, you normally do not need to change this
# value. SHOW INNODB STATUS will display the current amount used.
innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
# Size of each log file in a log group. You should set the combined size
# of log files to about 25%-100% of your buffer pool size to avoid
# unneeded buffer pool flush activity on log file overwrite. However,
# note that a larger logfile size will increase the time needed for the
# recovery process.
innodb_log_file_size = 5M
# The size of the buffer InnoDB uses for buffering log data. As soon as
# it is full, InnoDB will have to flush it to disk. As it is flushed
# once per second anyway, it does not make sense to have it very large
# (even with long transactions).
innodb_log_buffer_size = 1M
# If set to 1, InnoDB will flush (fsync) the transaction logs to the
# disk at each commit, which offers full ACID behavior. If you are
# willing to compromise this safety, and you are running small
# transactions, you may set this to 0 or 2 to reduce disk I/O to the
# logs. Value 0 means that the log is only written to the log file and
# the log file flushed to disk approximately once per second. Value 2
# means the log is written to the log file at each commit, but the log
# file is only flushed to disk approximately once per second.
innodb_flush_log_at_trx_commit = 0
innodb_lock_wait_timeout = 50
# Number of threads allowed inside the InnoDB kernel. The optimal value
# depends highly on the application, hardware as well as the OS
# scheduler properties. A too high value may lead to thread thrashing.
innodb_thread_concurrency=10

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
default-character-set=utf8
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates

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

[mysqlhotcopy]
interactive-timeout

 

 注意上边mysqld的字符集设置,以前版本的mysqld可以使用default-character-set=utf8,但是新版本那个参数已经删除了,必须使用character-set-server=utf8,否则日志中会记录错误:[ERROR] mysqld: unknown variable 'default-character-set=utf8'。

step3:配置文件写好之后,可以使用mysqld --defaults-file="E:\mysql-5.5.19\my.ini"命令来启动mysql。这时root账户不需要密码。基于最普通的安全考虑,你也应该给root账户设置一个密码。使用如下步骤:

 

use mysql;
update user set password = password('root');

 

 在这里最好使用password()函数,这样有两方面好处,一,设置的密码root是加密存储的。select * from user;时,你会看到密码是一串字符。二,这样做不用更改user表的authentication_string字段的设置。

注意这时有默认的匿名用户,如果不需要应该删掉,在user表中可以看到。

step4:设置完成密码之后,只有重启mysqld服务,更改才能生效。如果只是关闭cmd窗口显然是不起作用的,你在进程管理器中应该还能看到mysqld并没有关掉。必须另开一个cmd,使用如下语句:

 

mysqladmin shutdown -uroot -p

 然后再次启动mysqld就ok了,再次启动的时候,并不需要加上--defaults-file这个参数,如果你没有对它做修改的话。

 

如有错误敬请指正,渴望真像的脚步从未停歇。

分享到:
评论

相关推荐

    MySQL免安装版配置

    本文将深入解析如何配置MySQL免安装版,包括下载与解压、环境变量设置、服务安装、以及中文字符集的配置。 ### 1. 下载MySQL免安装版 首先,需访问MySQL官方网站或其他可信赖的资源平台,下载适合当前操作系统的...

    Mysql 8免安装版配置步骤

    1. **下载MySQL免安装压缩包**:首先,你需要从MySQL官方网站下载适用于你操作系统的免安装版本,例如`mysql-8.0.29-winx64`,这包含了运行MySQL所需的所有文件。 2. **解压并定位**:将下载的压缩包解压到你希望...

    MySQL5.7 免安装版配置

    MySQL5.7 免安装版配置 MySQL5.7 免安装版配置是指在 Windows 平台下,使用免安装的方式来配置 MySQL5.7 数据库管理系统。...MySQL5.7 免安装版配置需要遵循正确的安装步骤,配置好相关的参数,避免一些常见的错误。

    mysql免安装版安装配置.zip

    总之,MySQL免安装版提供了一种便捷的方式来使用和管理数据库,尤其适用于开发和测试环境。虽然配置过程可能涉及一些手动步骤,但只要遵循正确的指导,你就能成功地安装和配置MySQL 5.7免安装版。记得始终关注安全性...

    mysql免安装自动配置启动文件

    这个“mysql免安装自动配置启动文件”旨在简化MySQL的启动和关闭过程,无需经历传统的安装步骤,极大地提高了工作效率。 首先,让我们了解一下这个自动配置启动文件的工作原理。它通常包含了一系列的批处理脚本或...

    mysql免安装版配置

    与传统的安装版相比,免安装版更加灵活且便于携带。 #### 二、MySQL免安装版下载及解压 1. **下载**: 首先需要从MySQL官方网站或其他可信源下载适合Windows系统的免安装版MySQL压缩包,例如`mysql-noinstall-5.6.24...

    MySQL57免安装版配置文档

    通过以上步骤,我们成功完成了 MySQL5.7 免安装版的配置,并设置了 root 用户的初始密码。这些步骤不仅适用于 MySQL5.7 版本,对于其他版本的 MySQL 也同样适用。正确配置 MySQL 不仅能提高数据库的性能,还能增强...

    免安装版MySql运行详细步骤

    免安装版 mysql 免安装版本配置方法 详细步骤一步一步完成mysql的安装和使用 [mysql] #设置mysql客户端默认字符集 default-character-set=utf8 [mysqld] #设置3306端口 port = 3306 #设置mysql的安装目录 basedir=D:...

    mysql免安装教程

    #### 二、MySQL免安装版配置与安装步骤 ##### 1. 下载并解压MySQL 首先,从官方网站或其他可信来源下载MySQL免安装版压缩包。下载完成后,选择一个合适的路径进行解压。例如,可以将MySQL安装在`D:\ProgramFiles\...

    LinuxMySQL免安装及配置

    资源名称:Linux MySQL免安装及配置资源截图: 资源太大,传百度网盘了,链接在附件中,有需要的同学自取。

    MySql免安装-自动安装启动批处理.rar

    1. **MySQL免安装版**:免安装版的MySQL通常被称为绿色版或便携版,它不需要正式的安装过程,只需解压到指定目录即可使用。这种版本适合于快速部署、测试环境或者对系统资源有限制的情况。 2. **批处理文件(.bat)...

    mysql 免安装 windows 64 位平台

    ### MySQL免安装版在Windows 64位平台的配置与使用 #### 一、概述 在Windows 64位平台上部署MySQL服务器时,通常有两种方式:一种是传统的安装程序安装方式,另一种则是免安装的方式。本文主要介绍的是后者——...

    MySQL 5.7.9 ZIP 免安装版本配置过程

    ### MySQL 5.7.9 ZIP免安装版配置详解 #### 一、前言与背景 随着技术的发展,越来越多的人开始关注并学习数据库管理技术,其中MySQL作为一款流行的关系型数据库管理系统,备受青睐。对于初学者来说,选择一个合适...

    mysql免安装版及navicat数据库管理工具

    MySQL免安装版与Navicat数据库管理工具是IT领域中两个非常重要的组件,它们在数据库管理和开发工作中扮演着至关重要的角色。MySQL是一个流行的开源关系型数据库管理系统,而Navicat则是一款强大的数据库管理和开发...

    mysql免安装包配置文件

    my-default.ini相关,mysql免安装版本的配置相关,更多相关配置可以参考个人博客

    mysql免安装版配置.txt

    ### MySQL免安装版配置知识点详解 #### 一、MySQL免安装版概述 MySQL免安装版是一种无需进行传统安装过程即可使用的版本,适用于那些希望快速部署MySQL数据库环境的用户。相较于传统的安装程序,免安装版提供了...

    MySql 纯绿色免安装版本

    标题中的“MySQL 纯绿色免安装版本”指的是这个版本的MySQL不需要通过常规的安装程序进行安装,而是可以下载后直接解压到指定位置。这样的设计使得用户无需担心系统注册表的修改,避免了可能产生的系统冲突问题,...

Global site tag (gtag.js) - Google Analytics