1.下載 mysql-noinstall-5.1.62-win32.zip
2.加壓縮導任何一個目錄,最好目錄名稱不要有空格;
例如:D:\mysql-5.1.62
3,在mysql-5.1.62
目錄下新建一個my.ini,拷貝my-small.ini代碼至my.ini;修改后如下(中文說明為添加部分):
....# Example MySQL config file for small systems.
#
# This is for a system with little memory (<= 64M) where MySQL is only used
# from time to time and it's important that the mysqld daemon
# doesn't use much resources.
#
# MySQL programs look for option files in a set of
# locations which depend on the deployment platform.
# You can copy this option file to one of those
# locations. For information about these locations, see:
# http://dev.mysql.com/doc/mysql/en/option-files.html
#
# 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 =
port = 3306
socket = MySQL
#這里是我們增加的內容
#設置客戶端字符集
#default-character-set=utf8
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
port = 3306
socket = MySQL
skip-locking
key_buffer_size = 16K
max_allowed_packet = 1M
table_open_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 128K
#這里是我們修改的內容
basedir=L:\\mysql-noinstall-5.1.62-win32
# 設置mysql數據庫的數據的存放目錄,必須是data,或者是\\xxx\data
datadir=L:\\mysql-noinstall-5.1.62-win32\\xxdb\\data
# 設置mysql服務器的字符集
default-character-set=utf8
#Server=L:/mysql-noinstall-5.1.62-win32/bin/mysqld-nt.exe
# 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
# (using the "enable-named-pipe" option) will render mysqld useless!
#
#skip-networking
server-id = 1
# Uncomment the following if you want to log updates
#log-bin=mysql-bin
# binary logging format - mixed recommended
#binlog_format=mixed
# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = C:\\mysql\\data\\
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = C:\\mysql\\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 = 16M
#innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 5M
#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
[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
[mysqlhotcopy]
interactive-timeout
4,然后編寫啟動腳本startup.bat,放在D:\mysql-5.1.62\bin路徑下,此啟動腳本會將mysql5注冊到系統服務中:
@echo off
echo start mysql5 on localhost
mysqld --install mysql5 --defaults-file=D:\mysql-5.1.62\my.ini
net start mysql5
pause
5,停止腳本stop.bat放在D:\mysql-5.1.62\bin路徑下,停止腳本會將系統服務中MySQL5卸載掉:
@echo off
echo stop mysql5
net stop mysql5
mysqld --remove mysql5
pause
6.配置完畢后,雙擊D:\mysql-5.1.62\bin路徑下的startup.bat批處理文件,在系統服務中有一個mysql5的服務,並且已經啟動,然后測試下數據庫的安裝情況,在dos窗口下,進入D:\>cd D:\mysql-5.1.62\bin路徑下,輸入mysqlshow,即可顯示數據庫信息,
示例如下:
Microsoft Windows XP [版本 5.1.2600]
(C) 版權所有 1985-2001 Microsoft Corp.
C:\Documents and Settings\guoy>d:
D:\>cd D:\mysql-5.1.62\bin
D:\mysql-5.1.62\bin>mysqlshow
+--------------------+
| Databases |
+--------------------+
| information_schema |
| test |
+--------------------+
D:\mysql-5.1.62\bin>
如上信息說明數據庫安裝成功還有其他測試命令:
mysqlshow -u root mysql
mysqladmin -u root version status proc
免安裝版本,訪問MySQL時常會出現:access denied for user 'root'@'localhost' using password yes
出現這種情況多是root密碼沒有設置或錯誤,解決辦法如下:
1. 管理員登陸系統,停止 MySQL 服務或者結束 MySQL 進程。
2. 啟動 WINDOWS 的命令行窗口(即通常的 DOS 窗口),切換到你的 “MySQL\bin” 目錄下。
例如我的是 “D:\SERVER\MySQL5122\bin”,然后執行下面的粗體的命令:
(注意你的 “my.ini” 位置)
Microsoft Windows XP [版本 5.1.2600]
(C) 版權所有 1985-2001 Microsoft Corp.
C:\Documents and Settings\MMC>d:
D:\>cd D:\SERVER\MySQL5122\bin
D:\SERVER\MySQL5122\bin>mysqld --defaults-file="D:\SERVER\MySQL5122\my.ini" --console --skip-grant-tables
090801 4:43:54 InnoDB: Started; log sequence number 0 585546
090801 4:43:54 [ERROR] Can't open and lock privilege tables: Table 'mysql.servers' doesn't exist
090801 4:43:54 [Note] mysqld: ready for connections.
Version: '5.1.22-rc-community' socket: '' port: 3306 MySQL Community Server (GPL)
_
可能會出現一些警告信息和錯誤,但只要出現下面信息,就說明 MySQL 已經起來了。
Version: '5.1.22-rc-community' socket: '' port: 3306 MySQL Community Server (GPL)
3. 不關閉此命令行窗口,重新打開一個命令行窗口,同樣切到 “mysql\bin” 目錄下,然后執行下面的粗體的命令:
Microsoft Windows XP [版本 5.1.2600]
(C) 版權所有 1985-2001 Microsoft Corp.
C:\Documents and Settings\MMC>d:
D:\>cd D:\SERVER\MySQL5122\bin
D:\SERVER\MySQL5122\bin>mysql -u root mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.22-rc-community MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
到這步,我想任何一個使用 MySQL 的人都知道后面要做什么了!(^a^)
mysql>
mysql> UPDATE user SET Password=PASSWORD('mynewpass') where USER='root';
Query OK, 2 rows affected (0.05 sec)
Rows matched: 2 Changed: 2 Warnings: 0
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.02 sec)
mysql> quit
Bye
4. 好了到此步,可以關閉第一個 DOS 窗口了。打開系統服務控制窗口(控制面板--管理工具--服務),啟動 MySQL 服務。
5. 在剩下的第二個 DOS 窗口中,用新的 ROOT 密碼連接 MySQL。
D:\SERVER\MySQL5122\bin>mysql -u root -p
Enter password: ********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.22-rc-community MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> quit
Bye
至此,系統恢復 ROOT 用戶管理權限完成。
對於安裝版MYSQL完全卸載方法
第一次安裝mysql輸入密碼后,如果你想卸載重裝,便會出現要求輸入原來設定的密碼,否則安裝不成功。遇到這樣的問題,是你沒有完全卸載mysql數據庫。
MysqlQ完全卸載方法:
1.清除MYSQL的安裝目錄,默認是C:Program Files
2.清除MYSQL數據存放目錄,一般在C:programData目錄下(win7)或者C:Documents and SettingsAll Users.windowsApplication Data(XP)目錄下刪除MySQL文件夾。
(需要注意的時Application Data這個文件夾默認是隱藏的,要通過 工具->文件夾選項->查看->顯示所有文件與文件夾來設置隱藏文件可見)。
3.這步很重要,之前不管我怎么卸載MYSQL清空殘余文件都還是要輸入原始密碼,后來試試找了下注冊表,清空后果然有效。
刪除注冊表數據,通過regedit,刪除以下幾個文件:
HKEY_LOCAL_MACHINE/SYSTEM/ControlSet001/Services/Eventlog/Applications/MySQL
HKEY_LOCAL_MACHINE/SYSTEM/ControlSet002/Services/Eventlog/Applications/MySQL
HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/Eventlog/Applications/MySQL
至此Mysql數據庫便完全卸載了,然后重新安裝即可。
Windows下mysql忘記root密碼的解決方法
Mysql版本:5.1.55-community MySQL Community Server (GPL)
1、 首先檢查mysql服務是否啟動,若已啟動則先將其停止服務,可在開始菜單的運行,使用命令:
net stop mysql
或者在windows任務管理器中結束mysqld.exe進程,或者在控制面板,管理工具里面的服務找到mysql,將其停止服務。
打開第一個cmd窗口,切換到mysql的bin目錄,運行命令:
mysqld --defaults-file="C:Program FilesMySQLMySQL Server 5.1my.ini" --console --skip-grant-tables
注釋:
該命令通過跳過權限安全檢查,開啟mysql服務,這樣連接mysql時,可以不用輸入用戶密碼。
"C:Program FilesMySQLMySQL Server 5.1my.ini"指配置文件my.ini,一般在mysql安裝目錄里面。
如:
===============================================================================
C:Program FilesMySQLMySQL Server 5.1bin>mysqld --defaults-file="C:Program FilesMySQLMySQL Server 5.1my.ini" --console --skip-grant-tables
110301 9:20:07 [Warning] '--default-character-set' is deprecated and will be removed in a future release. Please use '--character-set-server' instead.
110301 9:20:07 [Note] Plugin 'FEDERATED' is disabled.
110301 9:20:07 InnoDB: Initializing buffer pool, size = 46.0M
110301 9:20:07 InnoDB: Completed initialization of buffer pool
110301 9:20:07 InnoDB: Started; log sequence number 0 44233
110301 9:20:07 [Note] mysqld: ready for connections.
Version: '5.1.55-community' socket: '' port: 3306 MySQL Community Server (GPL)
2、打開第二個cmd窗口,連接mysql:
輸入命令:
mysql -uroot -p
出現:
Enter password:
在這里直接回車,不用輸入密碼。
然后就就會出現登錄成功的信息,
如:
===============================================================================
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 3
Server version: 5.1.55-community MySQL Community Server (GPL)
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
mysql>
===============================================================================
使用命令:
show databases;
顯示已有數據庫:
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
3 rows in set (0.00 sec)
使用命令切換到mysql數據庫:
use mysql;
使用命令更改root密碼:
UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
刷新權限:
FLUSH PRIVILEGES;
然后退出,重新登錄:
quit
重新登錄:
mysql -uroot -p
出現輸入密碼提示,輸入新的密碼即可登錄:
Enter password: ***********
顯示登錄信息:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 9
Server version: 5.1.55-community MySQL Community Server (GPL)
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
mysql>
到這里root密碼就已經修改成功了,用Ctrl+C將第一個cmd窗口結束,那樣就會停止mysql服務,如:
=============================================================================== C:Program FilesMySQLMySQL Server 5.1bin>mysqld --defaults-file="C:Program F
ilesMySQLMySQL Server 5.1my.ini" --console --skip-grant-tables
110301 10:29:47 [Warning] '--default-character-set' is deprecated and will be re
moved in a future release. Please use '--character-set-server' instead.
110301 10:29:47 [Note] Plugin 'FEDERATED' is disabled.
110301 10:29:47 InnoDB: Initializing buffer pool, size = 46.0M
110301 10:29:47 InnoDB: Completed initialization of buffer pool
110301 10:29:48 InnoDB: Started; log sequence number 0 44233
110301 10:29:48 [Note] mysqld: ready for connections.
Version: '5.1.55-community' socket: '' port: 3306 MySQL Community Server (GPL)
(此處輸入ctrl+c)
110301 10:30:58 [Note] mysqld: Normal shutdown
110301 10:30:58 InnoDB: Starting shutdown...
110301 10:31:03 InnoDB: Shutdown completed; log sequence number 0 44233
110301 10:31:03 [Note] mysqld: Shutdown complete
Mysql服務停止了,輸入命令:
net start mysql,即可重新啟動mysql服務,如:
===============================================================================
C:Program FilesMySQLMySQL Server 5.1bin>net start mysql
MySQL 服務正在啟動 .
MySQL 服務已經啟動成功。
C:Program FilesMySQLMySQL Server 5.1bin>