鴻飛

导航

 

1、下载并解压

到官网下载mysql-5.5.10-win32.zip,然后将mysql解压到任意路径,如:C:\mysql-5.5.10-win32 

2、设置环境变量

打开计算机->属性->高级系统设置->环境变量,新建一个环境变量,变量名为:MYSQL_HOME,变量值为你的mysql根目录,如:C:\mysql-5.5.10-win32 
然后在系统变量Path中添加:;%MYSQL_HOME%\bin

3、安装mysql服务

以管理员身份打开命令提示符,执行命令:mysqld -installmysql服务安装到windows的服务

注:如果要卸载mysql服务,执行:mysqld -remove

4、启动mysql服务

执行:net start mysql

注:如果要停止mysql服务,执行:net stop mysql

5、设置密码

输入mysql -uroot进入mysql(默认root密码为空)

执行

mysql> use mysql ;
mysql> update user set password=password("new_pass") where user="root"; 
mysql> flush privileges; 
mysql> exit ;

6、登录

输入mysql -uroot -p回车

输入密码

 

如果忘记密码

步骤如下:
1.停止mysql服务

以管理员身份,在cmd命令行下运行: net stop mysql
2.使用 mysqld –skip-grant-tables 命令启动mysql数据库
C:\Windows\system32>net stop mysql
C:\Windows\system32>mysqld --skip-grant-tables

3.不关闭以上窗口,新开一个cmd窗口,输入mysql -u root,直接按回车键
C:\Windows\system32>mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.1.26-rc-community MySQL Community Server (GPL) Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> update mysql.user set password=password('sxm') where user='root';
密码可以自己随便写。

Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

4.停止mysql,mysqld进程

打开任务管理器,停止mysql和mysqld进程

5开启服务,正常登录

使用net start mysql启动mysqld服务,就可以使用root用户 root密码进入数据库了

mysql -u root -p sxm


补充说明:
1.mysqld使用说明可以使用如下命令获取查看:
mysqld --verbose --help > d:\mysqld_help.txt
帮助中–skip-grant-tables的帮助为:
--skip-grant-tables Start without grant tables. This gives all users FULL ACCESS to all tables!
所以我们可以使用mysql -uroot而不用密码直接登陆mysql,而且可以修改任何表。

posted on 2016-05-09 11:36  鴻飛  阅读(250)  评论(0编辑  收藏  举报