mysql-noinstall-5.1.62-win32 安装
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>