2016-06-12 回答
1、 mysql community server 5.6.10
2、解压到d:\mysql.(路径自己指定)
3、在d:\mysql下新建my.ini配置文件,内容如下:
*****************配置文件开始*********************
# mysql server instance configuration file
#----------------------------------------------------------------------
# generated by the mysql server instance configurationwizard
#
#
# installation instructions
#----------------------------------------------------------------------
#
#
# client section
#----------------------------------------------------------------------
#
# the following options will be read by mysql clientapplications.
# note that only client applications shipped by mysqlare guaranteed
# to read this section. if you want your own mysqlclient program to
# honor these values, you need to specify it as anoption 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 usuallyresolved relative to this.
basedir="d:\mysql\"
#path to the database root
datadir="d:\mysql\data"
[winmysqladmin]
server="d:\mysql\bin\mysqld.exe"
# the default character set that will be used when anew schema or table is
# created and no character set is defined
default-character-set=gbk
# the default storage engine that will be used whencreate 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 mysqlserver will
# allow. one of these connections will be reserved fora user with
# super privileges to allow the administrator to logineven if the
# connection limit has been reached.
max_connections=100
# query cache is used to cache select results andlater return them
# without actual executing the same query once again.having the query
# cache enabled may result in significant speedimprovements, if your
# have a lot of identical queries and rarely changingtables. see the
# "qcache_lowmem_prunes" status variable tocheck if the current value
# is high enough for your load.
# note: in case your tables change very often or ifyour queries are
# textually different every time, the query cache mayresult in a
# slowdown instead of a performance improvement.
query_cache_size=0
# the number of open tables for all threads.increasing this value
# increases the number of file descriptors that mysqldrequires.
# therefore you have to make sure to set the amount ofopen 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) temporarytables. if a table
# grows larger than this value, it is automaticallyconverted to disk
# based table this limitation is for a single table.there can be many
# of them.
tmp_table_size=26m
# how many threads we should keep in a cache forreuse. when a client
# disconnects, the client's threads are put in thecache if there aren't
# more than thread_cache_size threads frombefore. this greatly reduces
# the amount of thread creations needed if you have alot of new
# connections. (normally this doesn't give a notableperformance
# improvement if you have a good threadimplementation.)
thread_cache_size=8
#*** myisam specific options
# the maximum size of the temporary file mysql isallowed to use while
# recreating the index (during repair, alter table orload data infile.
# if the file-size would be bigger than this, theindex will be created
# through the key cache (which is slower).
myisam_max_sort_file_size=100g
# if the temporary file used for fast index creationwould be bigger
# than using the key cache by the amount specifiedhere, then prefer the
# key cache method. this is mainly used to force long character keys in
# large tables to use the slower key cache method tocreate the index.
myisam_sort_buffer_size=52m
# size of the key buffer, used to cache index blocksfor myisam tables.
# do not set it larger than 30% of your available memory,as some memory
# is also required by the os to cache rows. even ifyou're not using
# myisam tables, you should still set it to 8-64m asit will also be
# used for internal temporary disk tables.
key_buffer_size=40m
# size of the buffer used for doing full table scansof myisam tables.
# allocated per thread, if a full scan is needed.
read_buffer_size=64k
read_rnd_buffer_size=256k
# this buffer is allocated when mysql needs to rebuildthe index in
# repair, optimze, alter table statements as well asin load data infile
# into an empty table. it is allocated per thread sobe careful with
# large settings.
sort_buffer_size=256k
#*** innodb specific options ***
innodb_data_home_dir="d:\mysql\data\innodb\"
# use this option if you have a mysql server withinnodb support enabled
# but you do not plan to use it. this will save memoryand disk space
# and speed up some things.
#skip-innodb
# additional memory pool that is used by innodb tostore 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 needto change this
# value. show innodb status will display the currentamount used.
innodb_additional_mem_pool_size=2m
# if set to 1, innodb will flush (fsync) thetransaction logs to the
# disk at each commit, which offers full acidbehavior. if you are
# willing to compromise this safety, and you arerunning small
# transactions, you may set this to 0 or 2 to reduce diski/o to the
# logs. value 0 means that the log is only written tothe log file and
# the log file flushed to disk approximately once persecond. value 2
# means the log is written to the log file at eachcommit, but the log
# file is only flushed to disk approximately once persecond.
innodb_flush_log_at_trx_commit=1
# the size of the buffer innodb uses for buffering logdata. as soon as
# it is full, innodb will have to flush it to disk. asit is flushed
# once per second anyway, it does not make sense tohave it very large
# (even with long transactions).
innodb_log_buffer_size=1m
# innodb, unlike myisam, uses a buffer pool to cacheboth indexes and
# row data. the bigger you set this the less disk i/ois needed to
# access data in tables. on a dedicated databaseserver you may set this
# parameter up to 80% of the machine physical memorysize. do not set it
# too large, though, because competition of thephysical memory may
# cause paging in the operating system. note that on 32bit systems you
# might be limited to 2-3.5g of user level memory perprocess, so do not
# set it too high.
innodb_buffer_pool_size=77m
# size of each log file in a log group. you should setthe combined size
# of log files to about 25%-100% of your buffer poolsize to avoid
# unneeded buffer pool flush activity on log fileoverwrite. however,
# note that a larger logfile size will increase thetime needed for the
# recovery process.
innodb_log_file_size=39m
# number of threads allowed inside the innodb kernel.the optimal value
# depends highly on the application, hardware as wellas the os
# scheduler properties. a too high value may lead tothread thrashing.
innodb_thread_concurrency=8
*****************配置文件结束*********************
配置文件也放在了附件里,大家可以根据需要修改。
重点是以下配置,其中datadir的目录名称必须是data,并且好像必须是mysql目录下的data.之前自己制定了其他目录,一直出现1067的错误。
#path to installation directory. all paths are usuallyresolved relative to this.
basedir="d:\mysql\"
#path to the database root
datadir="d:\mysql\data"
4、在windows环境变量里加入以下内容(方便执行命令行命令)
新建mysql_home="d:\mysql\"
在path里加入%mysql_home%\bin
5、将mysql注册为windows系统服务。具体操作是在命令行中执行以下命令:
mysqld install mysql --defaults-file="d:\mysql\my.ini"
移除服务为 mysqld remove
6、第5步成功后,在命令行启动mysql
c:>net start mysql
7、修改root的密码为62386997
方法一:
c:>mysql –uroot
mysql>showdatabases;
mysql>use mysql;
mysql> update user set password=password("62386997") whereuser='root';
mysql> flush privileges;
mysql> quit
..