本博文的主要內容有
.MySQL Server 5.5系列的下載
.MySQL Server 5.5系列的安裝
.MySQL Server 5.5系列的使用
.MySQL Server 5.5系列的卸載
注意啊!
對於noinstall方式安裝的MySQL,系統的參數配置、服務的啟動和關閉都需要手工在命令窗口中完成。
對於圖形化方式安裝的MySQL,提供了一個圖形化的實例配置向導,可以引導用戶逐步進行實例參數的配置。
說明
首先,說明,在mysql官網里,沒有mysqlSetup.exe,這是自行修改的命名。
1、MySQL Server 5.5系列的下載
http://dev.mysql.com/downloads/mysql/5.0.html#linux
J 進入MySQL的官方網站
點擊“Downloads”。
首先在“Select Platform”下拉菜單中選擇“Microsoft Windows”平台,然后單擊"Windows (x86,32bit)",MSI Installer
選項右邊的Download按鈕,下載32位的MySQL安裝軟件。
http://dev.mysql.com/downloads/windows/installer/5.5.html
注意,MySQL 5.5是公認的穩定版本。
2、MySQL Server 5.5系列的安裝
1、新建MySQL Server目錄
2、安裝:雙擊Setup.exe文件,開始mysql的安裝。出現下面的窗口
3、點擊Next開始下一步安裝。默認是Typical,選擇Custom,(因為Typical模式不允許改變安裝路徑,只能安裝在C盤)
4、這里需要選擇組件和更改文件夾位置,組件可以默認的,位置要選擇Change來改變(
注意:安裝mysql的路徑中,不能含有中文)
5、點擊Install開始安裝
6、安裝完成,看到下面。當然,我們選擇“Skip Sign-Up”。
7、點擊完成“Finsh”
8、現在開始配置的工作了。點擊Next繼續。
選擇Detailed Configuration,點Next。
9、下面這個選項是選擇mysql應用類型
(第一種是開發服務器,將只用盡量少的內存,第二種是普通WEB服務器,將使用中等數量內存,最后一種是這台服務器上面只跑mysql數據庫,將占用全部的內存,)這里示例選擇開發服務器,占用盡量少的內存,用戶可根據自己的需求,選擇其他選項。這里,選擇“Developer machine”
10、接下來選擇數據庫用途,
(第一種是多功能用途,將把數據庫優化成很好的innodb存儲類型和高效率的myisam存儲類型,第二種是只用於事務處理類型,最好的優化innodb,但同時也支持myisam,最后一種是非事務處理類型,適合於簡單的應用,只有不支持事務的myisam類型是被支持的。)一般選擇第一種多功能。這里,選擇“Multifunctional Database”。
11、下面是選擇數據存放位置,默認。 選擇“Next”
12、選擇mysql允許的最大連接數,第一種是最大20個連接並發數,第二種是最大500個並發連接數,最后一種是自定義,你可以根據自己的需要選擇。
我這里,選擇“Decision Support(DSS)/OLAP”。
13、下面是選擇數據庫監聽的端口,一般默認是3306,如果改成其他端口,以后連接數據庫的時候都要記住修改的端口,否則不能連接mysql數據庫,比較麻煩,這里不做修改,用mysq的默認端口:3306。接下來默認latin1。
但是呢,這里,
MySQL Workbench類型之MySQL客戶端工具的下載、安裝和使用
已經安裝過一個MySQL客戶端了。(它已經占據了3306端口)。
所以,這里,選擇“3309”。
14、西文編碼,第二個是多字節的通用utf8編碼,都不是我們通用的編碼,這里選擇第三個,然后在Character Set那里選擇或填入“gbk”,當然也可以用“gb2312”,區別就是gbk的字庫容量大,包括了gb2312的所有漢字,並且加上了繁體字、和其它 亂七八糟的字——使用mysql的時候,在執行數據操作命令之前運行一次“SET NAMES GBK;”(運行一次就行了,GBK可以替換為其它值,視這里的設置而定),就可以正常的使用漢字(或其它文字)了,否則不能正常顯示漢字。當然我們腳本 是utf8編碼也可以在者選擇,也可以在創建數據庫的時候選擇按 “Next”繼續。
15、選擇是否將mysql安裝為windows服務,還可以指定Service Name(服務標識名稱),是否將mysql的bin目錄加入到Windows PATH(加入后,就可以直接使用bin下的文件,而不用指出目錄名,比如連接,“mysql.exe -uusername -ppassword;”就可以了,不用指出mysql.exe的完整地址,很方便),我這里全部打上了勾,Service Name不變。按“Next”繼續。選擇是否將mysql安裝為windows服務,還可以指定Service Name(服務標識名稱),是否將mysql的bin目錄加入到Windows PATH(加入后,就可以直接使用bin下的文件,而不用指出目錄名,比如連接,“mysql.exe -uusername -ppassword;”就可以了,不用指出mysql.exe的完整地址,很方便),我這里全部打上了勾,Service Name改變。按“Next”繼續。
由於,
所以,這里選擇“MySQL5”。
也是為了與MySQL Server 5.0方便對應!
16、這一步詢問是否要修改默認root用戶(超級管理)的密碼(默認為空),“New root password”如果要修改,就在此填入新密碼(如果是重裝,並且之前已經設置了密碼,在這里更改密碼可能會出錯,請留空,並將“Modify Security Settings”前面的勾去掉,安裝配置完成后另行修改密碼),“Confirm(再輸一遍)”內再填一次,防止輸錯。 “Enable root access from remote machines(是否允許root用戶在其它的機器上登陸,如果要安全,就不要勾上,如果要方便,就勾上它)”。最后“Create An Anonymous Account(新建一個匿名用戶,匿名用戶可以連接數據庫,不能操作數據,包括查詢)”,一般就不用勾了,設置完畢,按“Next”繼續。
17、確認設置無誤,如果有誤,按“Back”返回檢查。按“Execute”使設置生效。
需要一段時間...
18、設置完畢,按“Finish”結束mysql的安裝與配置——這里有一個比較常見的錯誤,就是不能“Start service”,一般出現在以前有安裝mysql的服務器上, 解決的辦法,先保證以前安裝的mysql服務器徹底卸載掉了;不行的話,檢查是否按上面一步所說,之前的密碼是否有修改,照上面的操作;如果依然還是不行,將 mysql安裝目錄下的data文件夾備份,然后刪除,在安裝完成后,將安裝生成的 data文件夾刪除,備份的data文件夾移回來,再重啟mysql服務就可以了,這種情況下,可能需要將數據庫檢查一下,然后修復一次,防止數據出錯。
容易出現的問題:mysql 安裝到最后一步時,start service 為失敗狀態。
- · 解決方法:
- 方式1 MySQL安裝是出現could not start the service mysql error:0 提示錯誤,解決方法: 首 先,在管理工具->服務里面將MySQL的服務給停止,然后打開cmd 進入你的MySQL bin目錄下,例如 C:\Program Files\MySQL\MySQL Server 5.0\bin 然后使用如下命令mysqld-nt -remove 然后就會顯示......success! 好了下面進入添加刪除程序,找到MySQL選擇卸載,記得選擇remove。最后將MySQL目錄刪除,還有數據庫的目錄也刪除
- · 方式2
- 查看服務中有沒有mysql,如果有將該服務停掉; 安裝mysql 5.1.33,在運行Server Instance Configuration wizard時的Execute configurattion步驟中的第三項Start Service進出錯,錯誤提示為Could not start the service MySQL (出現這種情況一般是因為裝過mysql,卸載不干凈造成的。卸載后重啟后再重裝。注意看下服務,如果未能卸載,可以用mysqld-nt -remove卸載)
- 在控制面板中運行添加刪除程序,將mysql卸載; 卸載后打開注冊表,查看
- HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services 下的鍵值,如果有相關mysql鍵值(mysql、mysqladmin)則刪掉,即可;
- 重啟,將mysql的安裝殘余目錄刪掉 (查看服務,此時服務中已沒有mysql); 重新安裝mysql.安裝后先不要運行Server Instance Configuration wizard,重啟后在開始菜單中運行該向導,即可
在這里啊,安裝好MySQL 之后,默認生產的文件情況,如下:
其中,
我這里,安裝之后,默認產生的my.ini配置文件的內容如下:
# 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=3309
[mysql]
default-character-set=latin1
# 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=3309
#Path to installation directory. All paths are usually resolved relative to this.
basedir="D:/SoftWare/MySQL Server/MySQL Server 5.0/"
#Path to the database root
datadir="D:/SoftWare/MySQL Server/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=latin1
# 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=100
# 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=0
# 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=5M
# 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=8
#*** MyISAM Specific options
# The maximum size of the temporary file MySQL is allowed to use while
# recreating the index (during REPAIR, ALTER TABLE or LOAD DATA INFILE.
# If the file-size would be bigger than this, the index will be created
# through the key cache (which is slower).
myisam_max_sort_file_size=100G
# If the temporary file used for fast index creation would be bigger
# than using the key cache by the amount specified here, 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 to create the index.
myisam_max_extra_sort_file_size=100G
# If the temporary file used for fast index creation would be bigger
# than using the key cache by the amount specified here, 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 to create the index.
myisam_sort_buffer_size=8M
# Size of the Key Buffer, used to cache index blocks for 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 if you're not using
# MyISAM tables, you should still set it to 8-64M as it will also be
# used for internal temporary disk tables.
key_buffer_size=8M
# Size of the buffer used for doing full table scans of 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 rebuild the index in
# REPAIR, OPTIMZE, ALTER table statements as well as in LOAD DATA INFILE
# into an empty table. It is allocated per thread so be careful with
# large settings.
sort_buffer_size=212K
#*** INNODB Specific options ***
# Use this option if you have a MySQL server with InnoDB support enabled
# but you do not plan to use it. This will save memory and disk space
# and speed up some things.
#skip-innodb
# 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
# 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=1
# 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
# InnoDB, unlike MyISAM, uses a buffer pool to cache both indexes and
# row data. The bigger you set this the less disk I/O is needed to
# access data in tables. On a dedicated database server you may set this
# parameter up to 80% of the machine physical memory size. Do not set it
# too large, though, because competition of the physical 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 per process, so do not
# set it too high.
innodb_buffer_pool_size=8M
# 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=10M
# 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
點擊“Finish”按鈕后,安裝過程全部完成。這時可以發現,Windows的服務列表中已經增加了“MySQL5”這一選項。
可以通過啟動、停止這個服務來啟動和關閉MySQL。
3、MySQL Server 5.5系列的使用
因為,這是對於采用圖形化方式安裝的MySQL,可以直接通過Windows的“開始”菜單 --> “控制面板” --> "管理工具" --> “服務”菜單。
來啟動和關閉MySQL5。
當然,也可以,通過命令行來,手工啟動和關閉MySQL5服務。
這里,學會使用技巧,
在命令提示符(cmd)下怎樣復制粘貼(詳細版)
http://jingyan.baidu.com/article/1876c852bcab82890b13768f.html
版權所有 (c) 2009 Microsoft Corporation。保留所有權利。
C:\Users\Administrator>cd /d D:\
D:\>cd D:\SoftWare\MySQL Server\MySQL Server 5.0\bin
D:\SoftWare\MySQL Server\MySQL Server 5.0\bin>net stop mysql5 (默認開機,mysql5服務是啟動的)
MySQL5 服務正在停止..
MySQL5 服務已成功停止。
D:\SoftWare\MySQL Server\MySQL Server 5.0\bin>net start mysql5
MySQL5 服務正在啟動 .
MySQL5 服務已經啟動成功。
D:\SoftWare\MySQL Server\MySQL Server 5.0\bin>mysql -u root -p
Enter password: ******** (rootroot)
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 5.0.22-community-nt
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
3 rows in set (0.00 sec)
mysql>
得到,默認,是以上的一些數據庫。
4、MySQL Server 5.5系列的卸載
路徑優點出入,自行對比參考。
感謝下面博主:
http://www.cnblogs.com/xiaoxiaojia/p/5366704.html
推薦書籍: