当前位置:网站首页>Solve MySQL 1045 access denied for user 'root' @ 'localhost' (using password: yes)
Solve MySQL 1045 access denied for user 'root' @ 'localhost' (using password: yes)
2022-07-03 13:50:00 【Procedural ape Dabo】
I have a problem recently , Just can't connect to the backstage mysql database , use navicat Open the database prompt 1045 Access denied for user 'root'@'localhost' (using password: YES). There is a solution to this problem online , But the whole network has copied one person , And did not give exactly what caused the problem . Today, I will explain the reason for this problem and two ways to solve it !

reason :
1. The database password has been tampered !
you 're right , That's why . But many people will immediately refute , My own computer has been working well , How could it be tampered with ? Hackers are powerful , Tampering with your database password is not the main purpose , The purpose is to enter your database after tampering, back up the database files, and then delete the local database , Threatening you to ask for bitcoin is the main purpose .
2. Database permissions have changed !
This reason has a lot to do with the change of account permissions of your machine , There are many actual scenarios , No more examples .
Here are two solutions , According to personal preferences, any one can
Method 1 :
edit mysql The configuration file my.ini( stay mysql Installation directory , Different computers may be different , Refer to the directory ①D:\Program Files\MySQL\MySQL Server 5.0\my.ini;②C:\ProgramData\MySQL\MySQL Server 8.0\my.ini;), stay [mysqld] Add... Under this item skip-grant-tables Save, exit and restart mysql
1. open cmd, Click on “ Start ”->“ function ”( Shortcut key Win+R).
2. stop it : Input net stop mysql
3. start-up : Input net start mysql
It can also be on the computer - management - Found in the service MySQL Service for , Pictured

At this time cmd In the input mysql -u root -p You can log in without a password , appear password: You can enter when you enter , There will be no ERROR 1045 (28000), But many operations are limited , Because no grant jurisdiction .
Continue to follow the following process :
1. Get into mysql database :
mysql> use mysql;
Database changed
2. to root The user sets a new password :
mysql> update user set password=password(" New password ") where user="root";
Query OK, 1 rows affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
3. Refresh database
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
4. sign out mysql:
mysql> quit;
Bye
After being changed , Let me revise it a little bit my.ini This file , Take what we just joined "skip-grant-tables" This line is deleted , Save, exit and restart mysql service , Reuse Navicat Just connect .

Method 2 :
Uninstall the original database , Including main program 、 Registry and C Disk folder , But you must pay attention to backup C disc C:\ProgramData\MySQL\MySQL Server ( The database version you uninstalled )\data The following database file , This is your previous database table file , To restore the database, you must back it up , Data can be recovered later . Besides , This folder is hidden by default .
Copy data Under the folder, the database you created before , Names are corresponding , You can know which database you created when you have an impression , There are also three files that must be backed up , Look at the picture :

After backing up these files , Uninstall the original database program and delete the folder and registry , Shut down the database service after reinstalling the database , Put the backup file in the corresponding location , Click to replace those with duplicate names , Then restart the database service . At this time, open the database , You will find that the original database has appeared , It's as like as two peas !
边栏推荐
- JS 将伪数组转换成数组
- 双向链表(我们只需要关注插入和删除函数)
- Universal dividend source code, supports the dividend of any B on the BSC
- Depth and breadth first traversal of tree (regardless of binary tree)
- Which securities company has the lowest Commission for opening an account online? I want to open an account. Is it safe for the online account manager to open an account
- JVM系列——概述,程序计数器day1-1
- MySQL 数据增删改查综合案例
- Spark practice 1: build spark operation environment in single node local mode
- Go: send the get request and parse the return JSON (go1.16.4)
- Flutter dynamic | fair 2.5.0 new version features
猜你喜欢

This math book, which has been written by senior ml researchers for 7 years, is available in free electronic version

Ocean CMS vulnerability - search php

Go language web development series 30: gin: grouping by version for routing

使用vscode查看Hex或UTF-8编码

Resource Cost Optimization Practice of R & D team

Complete DNN deep neural network CNN training with tensorflow to complete image recognition cases

使用tensorflow进行完整的DNN深度神经网络CNN训练完成图片识别案例

Halcon combined with C # to detect surface defects -- Halcon routine autobahn

Flutter dynamic | fair 2.5.0 new version features

Go language unit test 3: go language uses gocovey library to do unit test
随机推荐
User and group command exercises
[机缘参悟-37]:人感官系统的结构决定了人类是以自我为中心
Swiftui development experience: the five most powerful principles that a programmer needs to master
顺序表(C语言实现)
CVPR 2022 | 美团技术团队精选6篇优秀论文解读
mysql中的字段问题
Using registered classes to realize specific type matching function template
IBEM mathematical formula detection data set
[today in history] July 3: ergonomic standards act; The birth of pioneers in the field of consumer electronics; Ubisoft releases uplay
[bw16 application] instructions for firmware burning of Anxin Ke bw16 module and development board update
从零开始的基于百度大脑EasyData的多人协同数据标注
掌握Cypress命令行选项,是真正掌握Cypress的基础
The shadow of the object at the edge of the untiy world flickers, and the shadow of the object near the far point is normal
Software testing is so hard to find, only outsourcing offers, should I go?
JSON serialization case summary
Stack application (balancer)
Unity render streaming communicates with unity through JS
Use docker to build sqli lab environment and upload labs environment, and the operation steps are provided with screenshots.
栈应用(平衡符)
SQL Injection (GET/Search)