错误1045 Access denied for user 'root'@'localhost' (using password:YES)
2.百度的大部分方法都试过,什么修改my.ini文件,修改mySql中的root密码,地址改为127.0.0.1都不行。
3.我已正确安装mysql-5.6.39-winx64和Navicat for mySql,系统中存在MySQL服务,服务启动仍然报1045错误。
4.这个问题搞了好久,最后抱着最后一试的想法决定重新安装mySql服务。
以下为解决步骤:
1)在安装的mysql-5.6.39-winx64目录中,存在my-default.ini文件,将其删除
2)在当前目录下新建一个文本文件,将以下代码拷贝进去,并命名为my.ini
注意:basedir = "D:\mysql-5.6.39-winx64\mysql-5.6.39-winx64"
datadir = "D:\mysql-5.6.39-winx64\mysql-5.6.39-winx64\data"
Server = "D:\mysql-5.6.39-winx64\mysql-5.6.39-winx64\bin\mysqladmin.exe"
这三条语句应修改为自己安装对应的目录!!!!!!!
# *** upgrade to a newer version of MySQL.
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
basedir = "D:\mysql-5.6.39-winx64\mysql-5.6.39-winx64"
datadir = "D:\mysql-5.6.39-winx64\mysql-5.6.39-winx64\data"
port = 3306
# server_id = .....
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
#设置数据库引擎为INNODB
default-storage-engine=INNODB
# 设置mysql服务器编码
character_set_server=utf8
# 设置mysql服务器字符集
collation-server=utf8_general_ci
port = 3306
server_id = 1
[client]
default-character-set = utf8
[WinMySQLAdmin]
Server = "D:\mysql-5.6.39-winx64\mysql-5.6.39-winx64\bin\mysqladmin.exe"
3)编辑完成后保存,回到桌面,右键"我的电脑"--"属性"--"高级系统设置"--"环境变量"--打开"PATH"编辑框,在尾部添加mysql解文件的bin目录,并以";"结尾',编辑完后点确定关闭窗口;
4)打开"命令提示符","cmd"进入控制台,输入"mysqld --install"安装mysql服务;
5)继续输入"net start mysql",出现图下结果说明大功告成了;
6)此时,我们需要为mysql默认管理员"root"设置密码:执行"mysqladmin -u root password 123456"即可;
7)打开Navicat for mySql,连接数据库,可以看到数据库成功连接,没有再报错