windows下安装解压缩mysql
转载:http://jingyan.baidu.com/article/f3ad7d0ffc061a09c3345bf0.html
-
解压之后可以将该文件夹改名,放到合适的位置,个人建议把文件夹改名为MySQL Server 5.6,放到C:\Program Files\MySQL路径中。当然你也可以放到自己想放的任意位置。
-
完成上述步骤之后,很多用户开始使用MySQL,但会出现图示的错误。这是因为没有配置环境变量所致。配置环境变量很简单:
我的电脑->属性->高级->环境变量
选择PATH,在其后面添加: 你的mysql bin文件夹的路径 (如:C:\Program Files\MySQL\MySQL Server 5.6\bin )
PATH=.......;C:\Program Files\MySQL\MySQL Server 5.6\bin (注意是追加,不是覆盖)
-
配置完环境变量之后先别忙着启动mysql,我们还需要修改一下配置文件(如果没有配置,之后启动的时候就会出现图中的错误哦!:错误2 系统找不到文件),mysql-5.6.1X默认的配置文件是在C:\Program Files\MySQL\MySQL Server 5.6\my-default.ini,或者自己建立一个my.ini文件,
在其中修改或添加配置(如图):
[mysqld]
basedir=C:\Program Files\MySQL\MySQL Server 5.6(mysql所在目录)
datadir=C:\Program Files\MySQL\MySQL Server 5.6\data (mysql所在目录\data)
-
以管理员身份运行cmd(一定要用管理员身份运行,不然权限不够),
输入:cd C:\Program Files\MySQL\MySQL Server 5.6\bin 进入mysql的bin文件夹(不管有没有配置过环境变量,也要进入bin文件夹,否则之后启动服务仍然会报错误2)
输入mysqld -install(如果不用管理员身份运行,将会因为权限不够而出现错误:Install/Remove of the Service Denied!)
安装成功
-
安装成功后就要启动服务了,继续在cmd中输入:net start mysql(如图),服务启动成功!
此时很多人会出现错误,请看注意:
注意:这个时候经常会出现错误2和错误1067。
如果出现“错误2 系统找不到文件”,检查一下是否修改过配置文件或者是否进入在bin目录下操作,如果配置文件修改正确并且进入了bin文件夹,需要先删除mysql(输入 mysqld -remove)再重新安装(输入 mysqld -install);
如果出现错误1067,那就是配置文件修改错误,确认一下配置文件是否正确。
-
服务启动成功之后,就可以登录了,如图,输入mysql -u root -p(第一次登录没有密码,直接按回车过),登录成功!
Microsoft Windows XP [版本 5.1.2600]
(C) 版权所有 1985-2001 Microsoft Corp.
C:\Documents and Settings\Administrator>d:
D:\>cd d:/Mysql_win32\mysql-5.6.15\bin
D:\Mysql_win32\mysql-5.6.15\bin>mysqld -install
Service successfully installed.
D:\Mysql_win32\mysql-5.6.15\bin>net start mysql
MySQL 服务正在启动 .........
MySQL 服务已经启动成功。
D:\Mysql_win32\mysql-5.6.15\bin>mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.15-enterprise-commercial-advanced MySQL Enterprise Server -
Advanced Edition (Commercial)
Copyright (c) 2000, 2013, 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.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> set password for [email protected] = password('123456');
Query OK, 0 rows affected (0.09 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.02 sec)
mysql> quit。
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'quit
。' at line 1
mysql> quit
Bye
D:\Mysql_win32\mysql-5.6.15\bin>mysql -u root -p123456
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.15-enterprise-commercial-advanced MySQL Enterprise Server -
Advanced Edition (Commercial)
Copyright (c) 2000, 2013, 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.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
转载于:https://blog.51cto.com/526869727/1768544