您的位置:首页 > 数据库 > MySQL

mysql-5.7.17-winx64 win10 安装指南 和 修改root 密码

2017-03-13 19:38 806 查看
(也许有很多人跟我遇过到同样的问题)
======================================================================================
首先,我是照着这个链接安装的: http://blog.csdn.net/rebirth_love/article/details/53608483 数据库可以安装成功,但是服务不能启动。
其中评论区有提到,要在第四步执行mysqld --initialize --user=mysql --console 初始化

但是按照他这样做还是不成功,我是装在D盘,D:\mysql-5.7.17-winx64\

首先,如果你不是在D:\mysql-5.7.17-winx64\bin 

比如你在cmd 默认目录下执行mysqld --initialize --user=mysql --console ,则会提示: [ERROR]
Can't find error-message file 'C:\WINDOWS\system32\%MYSQL_HOME%\share\errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.

所以是目录不对,要切到D:\mysql-5.7.17-winx64\bin 目录,但是还是提示: [ERROR] Can't find error-message
file 'D:\mysql-5.7.17-winx64\bin\%MYSQL_HOME%\share\%MYSQL_HOME% hare\english\errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.

明显目录不对,于是我就把参考链接中的配置脚本上,关于配置目录的全部注释掉,OK ,默认目录都是对的了。成功!

附上操作图片和最后的my.ini 配置脚本。



#########################################################
    [client]
    port=3306
    default-character-set=utf8
    [mysqld]
    #basedir=%MYSQL_HOME%
    #解压目录
    #language=%MYSQL_HOME%\share\english
    port=3306
    character_set_server=utf8
    #datadir=%MYSQL_HOME%\data
    #解压目录下data目录
    sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
    [WinMySQLAdmin]
    %MYSQL_HOME%\bin\mysqld.exe
########

==========================分界线=============================================================================================

刚安装好后,按道理是没有root密码的,但是我这就是有密码,而且我还不知道密码,显示如下:

D:\>mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

D:\>mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

处理方法是在my.ini 文件里[mysqld]下面添加一句:skip-grant-tables
                   顾名思义,数据库启动的时候
跳跃权限表的限制,不用验证密码,直接登录。
net stop MySQL 关闭数据库服务,然后net start MySQL 打开,

这个时候在登录就不需要密码了,显示如下:
D:\>mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.17 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> update user set authentication_string=password('123123') where user='root' and Host='localhost' 

============================================================
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: