win7下安装mysql
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了win7下安装mysql相关的知识,希望对你有一定的参考价值。
(1)官网下载mysql:
http://dev.mysql.com/downloads/mysql/
(2)解压后,进入到该目录下,将my-default.ini文件复制一份改名为my.ini
打开my.ini找到对应行,进行修改:
basedir = D:\mysql-5.7.15-winx64datadir = D:\mysql-5.7.15-winx64\data port = 3306
(3)设置环境变量:
#计算机—>系统属性—>高级系统配置—>环境变量 #找到Path并编辑,在后面追加路径 ;D:\mysql-5.7.15-winx64\bin(注意前面加上分号) 变量名:mysql 变量值:D:\mysql-5.7.15-winx64\bin
(4)以管理员身份运行cmd命令行安装mysql,进入到bin目录:
C:\Windows\system32> d: D:\> D:\>cd mysql-5.7.15-winx64/bin D:\mysql-5.7.15-winx64\bin> mysqld -install Service successfully installed. D:\mysql-5.7.15-winx64\bin>mysqld --initialize D:\mysql-5.7.15-winx64\bin> net start mysql MySQL 服务正在启动 . MySQL 服务已经启动成功。
常用操作:
------------------------------------ mysqld --romve #删除mysql服务 mysqld --install #安装mysql服务 mysqld --initialize #一定要初始化 net start mysql #启动mysql服务 ------------------------------------
(5)登录数据库:
mysql:mysql –u root –p
如果出现报错:
ERROR 1045 (28000): Access denied for user ‘ODBC‘@‘localhost‘ (using password: NO) ERROR 1045 (28000): Access denied for user ‘ODBC‘@‘localhost‘ (using password: YES)
解决方法:
#(1)找到配置文件my.ini ,然后将其打开,在[mysqld]下面添加一行:skip-#grant-tables。保存退出。重启服务。输入mysql -u root -p就可以不用密码登录了,出现password:的时候直接回车可以进入。
#(2)进入数据库后给root用户设置新密码:update user set #password=password("123456") where user="root";
#(3)刷新数据库:flush privileges;
C:\Users\Administrator> mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.15 MySQL Community Server (GPL) Copyright (c) 2000, 2016, 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>
以上是关于win7下安装mysql的主要内容,如果未能解决你的问题,请参考以下文章