2015-05-25 回答
1.按照提示安装好mysql
2.运行cmd 进入mysql的安装目录,我的安装目录c:\program files\mysql\mysql server 5.6\bin
输入 cd c:\program files\mysql\mysql server 5.6\bin
3.采用mysqld将mysql注册为服务,命令为:mysqld -install mysql
4.启动服务:net start mysql
5.然后登陆,因为root用户的默认密码为空,直接回车进入
mysql -u root -p
6.① show databases;
② use mysql;
③ set password for 'root'@'localhost' = password('123456');
④ quit;
至此登录问题解决
[sql] view plaincopyprint?
#添加一个可远程登录的帐号user,且设置密码123456,能访问所有库 如远程无法访问关闭防火墙或添加入站出站规则,添加端口3306
grant all privileges on *.* to 'user'@'%' identified by '123456' with grant option;
flush privileges;
#mysql 添加用户user1并授权访问指定数据库db123,且设置密码333333
grant all privileges on db123.* to 'user1'@'%' identified by '333333' with grant option;
flush privileges;
#mysql 添加用户user2并授权访问指定数据库db123,且设置密码666666,同时限制登录为指定ip段
grant all privileges on db123.* to 'user2'@'192.168.104.%' identified by '666666' with grant option;
flush privileges;