一、卸载以前旧版本(本人5.7版本)
1、关闭MySQL服务
以管理员身份运行cmd,执行以下命令:
net stop mysql
或者右键我的电脑,在管理——服务——停止MySQL
2、卸载MySQL应用
mysqld -remove [服务名]
服务名称可以在右键我的电脑,在管理——服务——右键点击MySQL查看属性找到:如下图
3、删除MySQL文件
下面的将本地MySQL文件删除掉,路径可通过上图服务名称下面的可执行文件的路径查到。
4、删除注册表信息
开始->运行-> regedit 看看注册表里这几个地方删除没有
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Eventlog\Application\MySQL 目录删除 HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Services\Eventlog\Application\MySQL 目录删除 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application\MySQL 目录删除
注册表中的ControlSet001、ControlSet002不一定是001和002,可能是ControlSet005、006之类,删除的时候都删除就可以 。
完成以上四步即可成功卸载MySQL解压版环境。
二、安装MySQL5.6解压版
1.下载MYSQL的安装包
可以去官网下载ZIP包,http://www.mysql.com/downloads/mysql/点击打开链接
我安装的是mysql-5.6.35-winx64
2.解压到本地目录
E:\mysql-5.6.35-winx64
3.添加系统环境变量
添加系统环境变量是为了在命令控制窗口里更方便点。
新建:MYSQL_HOME ==> E:\mysql-5.6.35-winx64
追加:PATH==> ;%MYSQL_HOME%\bin
4. 修改mysql-5.6.35-winx64的配置文件:my-default.ini
在[mysqld]下追加
-------
basedir=E:\mysql-5.6.35-winx64
datadir=E:\mysql-5.6.35-winx64\data
character-set-server = utf8
-------
5.安装MySQL5.6应用
保存my-default.ini的配置,
然后打开命令行(开始菜单==>运行==>cmd )
输入: mysqld --console 然后回车将看到如下类似内容:
-------
C:\Windows\system32>mysqld --console
120410 14:25:22 [Note] Plugin 'FEDERATED' is disabled.
120410 14:25:22 InnoDB: The InnoDB memory heap is disabled
120410 14:25:22 InnoDB: Mutexes and rw_locks use Windows interlocked functions
120410 14:25:22 InnoDB: Compressed tables use zlib 1.2.3
120410 14:25:22 InnoDB: Initializing buffer pool, size = 128.0M
120410 14:25:22 InnoDB: Completed initialization of buffer pool
120410 14:25:22 InnoDB: highest supported file format is Barracuda.
120410 14:25:22 InnoDB: Waiting for the background threads to start
120410 14:25:23 InnoDB: 1.1.8 started; log sequence number 1595675
120410 14:25:23 [Note] Event Scheduler: Loaded 0 events
120410 14:25:23 [Note] mysqld: ready for connections.
Version: '5.5.22' socket: '' port: 3306 MySQL Community Server (GPL)
-------
==> 证明mysql服务已启动
6. 设置登陆mysql root帐号的的密码
打开新的命令行,输入 mysql -uroot 回车
-------
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.22 MySQL Community Server (GPL)
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. www.2cto.com
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
-------
==〉看到上面类似内容说明登陆成功,此时的root帐号是没有密码的
执行命令修改密码:
use mysql;
update user set password=PASSWORD("这里填写你要设置的密码") where user='root';
执行完成后退出mysql操作,然后关闭mysql服务,然后重启mysql服务
然后使用你的root帐号登录
命令:mysql -u root -p //root是用户名,输入这条命令按回车键后系统会提示你输入密码
//然后你输入正确的密码,再按一下回车键就可以登录MySQL数据库了。
(也可以使用
mysqladmin -u root password 你的密码
) 这个应该适用Win7
这样就可以正常登录了。
系统为WIN7,在cmd下使用"net start MySQL"提示"服务名无效,青键入net helpmsg 2185 以获得更多帮助"错误
原因是mysql没有加入到window的服务中
解决方法是命令行进入mysql安装路径,输入mysqld --install
例如 安装路径为D:\Program Files\MySQL,再进去bin目录,mysqld --install
(安装路径为D:\Program Files\MySQL)
回车,提示成功,接下来,就可以在我的电脑的服务里面找到mysql服务,去设置自动启动就OK了。
三、附安装MySQL5.7解压版教程
1.下载MYSQL的安装包
可以去官网下载ZIP包,http://www.mysql.com/downloads/mysql/点击打开链接
2.解压
解压到想安装的目录下,我的是D:\mysql-5.7.17-winx64
3.添加系统环境变量
添加系统环境变量是为了在命令控制窗口里更方便点。
新建:MYSQL_HOME ==>D:\mysql-5.7.17-winx64
追加:PATH==> ;%MYSQL_HOME%\bin
4. 修改mysql-5.7.17-winx64的配置文件:my-default.ini
在[mysqld]下追加
-------
basedir=D:\mysql-5.7.17-winx64
datadir=D:\mysql-5.7.17-winx64\data
character-set-server = utf8
port=3306
-------
5.安装MySQL5.7应用
保存my-default.ini的配置,
然后打开命令行(开始菜单==>运行==>cmd )
输入: mysqld --console 然后回车将看到如下类似内容:
-------
C:\Windows\system32>mysqld --console
120410 14:25:22 [Note] Plugin 'FEDERATED' is disabled.
120410 14:25:22 InnoDB: The InnoDB memory heap is disabled
120410 14:25:22 InnoDB: Mutexes and rw_locks use Windows interlocked functions
120410 14:25:22 InnoDB: Compressed tables use zlib 1.2.3
120410 14:25:22 InnoDB: Initializing buffer pool, size = 128.0M
120410 14:25:22 InnoDB: Completed initialization of buffer pool
120410 14:25:22 InnoDB: highest supported file format is Barracuda.
120410 14:25:22 InnoDB: Waiting for the background threads to start
120410 14:25:23 InnoDB: 1.1.8 started; log sequence number 1595675
120410 14:25:23 [Note] Event Scheduler: Loaded 0 events
120410 14:25:23 [Note] mysqld: ready for connections.
Version: '5.7.17' socket: '' port: 3306 MySQL Community Server (GPL)
-------
==> 证明mysql服务已启动
6. 设置登陆mysql root帐号的的密码
打开新的命令行,输入 mysql -uroot 回车
-------
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.7.17 MySQL Community Server (GPL)
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. www.2cto.com
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
-------
==〉看到上面类似内容说明登陆成功,此时的root帐号是没有密码的
执行命令修改密码:
use mysql;
update mysql.user set authentication_string=password('这里填写你要设置的密码') where user='root' and host='localhost';
执行完成后退出mysql操作,然后关闭mysql服务
7.cmd 终端下,进入到mysql安装目录,再进去bin目录,如下图:
执行 :
mysqld --install MySQL57 --defaults-file="D:\mysql-5.7.17-winx64\my-default.ini"
将mysql服务加入到window的服务中,然后在 我的电脑 - 右键 - 管理-在服务中找到mysql -右键启动
然后使用你的root帐号登录
打开CMD,命令:mysql -u root -p //root是用户名,输入这条命令按回车键后系统会提示你输入密码
//然后你输入正确的密码,再按一下回车键就可以登录MySQL数据库了。