Solve the problem of MySQL 8.0 still prompting Access denied even though the input is correct

Solve the problem of MySQL 8.0 still prompting Access denied even though the input is correct

I started learning MySQL recently. The installation went smoothly and I was able to install it successfully by following the ready-made tutorials on the Internet.

However, when entering

mysql -uroot -p

When I entered the password again, I encountered this situation

Access denied for user 'root'@'localhost' (using password: YES)

I have found many solutions online, but there is basically only one solution, which is to add the mysqld entry in the .ini file

skip-grant-tables

Then restart the server and follow the steps again (without entering the password at the end), but there is still a statement that stops me

Access denied for user 'root'@'localhost' (using password: NO)

I combined many methods on the Internet, tried them one by one, and finally succeeded.

The overall idea is to modify the contents of the .ini configuration file, but it is modified through the command line. I don’t know if it is because the version iteration has blocked the previous method of directly modifying the file. In any case, it is possible to modify it through the command line on MySQL 8.0.

Let’s get started.

Open cmd as an administrator and switch to the bin directory of MySQL

Shutdown the MySQL Server

net stop mysql

Skip the password input step (note: the file name and path must match your own)

mysqld --defaults-file="D:\MySQL\my.ini" --console --skip-grant-tables

If a statement similar to the one circled in the screenshot appears, it means success

Restart the server

net start mysql

Log in to MySQL server

mysql -uroot -p

After entering the password, you can log in successfully. (The number 1 is very similar to the letter l)

At this point, it's almost done, but when I type

show databases;

The feedback from MySQL is:

You must reset your password using ALTER USER statement before executing this statement.

My guess is that MySQL thinks the random password provided during installation is insecure and asks the user to reset the password.

I searched online and found a ready-made solution.

Reference article: https://dev.mysql.com/doc/refman/5.7/en/alter-user.html

Password never expires

ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password' PASSWORD EXPIRE NEVER;

Password has a limited time

ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password' PASSWORD EXPIRE;

Then log in to the server again and it will work normally.

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Solution to the problem of Access denied for user'root'@'localhost' (using password: YES) in MySQL 8.0 login under win10
  • How to solve the error when connecting to MySQL in Linux: Access denied for user 'root'@'localhost'(using password: YES)
  • Solution to the Mysql ERROR 1045 (28000): Access denied for user root@localhost problem in Ubuntu system
  • Solve the problem of Access denied for user ''root''@''%'' to database ''xxx'' after creating a database in MySQL
  • Solve the problem of ERROR 1045 (28000): Access denied for user ''root''@''localhost'' when logging in after installing MySQL 5.7.17 on Ubuntu 16.04
  • After installing MySQL, the root account prompt appears when logging in. mysql ERROR 1045 (28000): Access denied for use solution
  • mysql Access denied for user 'root'@'localhost' (using password: YES) solution

<<:  JavaScript to achieve full or reverse selection effect in form

>>:  After restarting the Baota panel, it prompts -ModuleNotFoundError: No module named 'geventwebsocket'

Recommend

Two methods of implementing automatic paging in Vue page printing

This article example shares the specific code of ...

Proxy realizes the principle of two-way binding of Vue3 data

Table of contents 1. Advantages of proxy vs. Obje...

Detailed explanation of CSS animation attribute keyframes

How long has it been since I updated my column? H...

Brief analysis of mysql scheduled backup tasks

Introduction In a production environment, in orde...

Example analysis of mysql user rights management

This article describes the MySQL user rights mana...

Vue implements a search box with a magnifying glass

This article shares with you how to use Vue to im...

Summary of 10 advanced tips for Vue Router

Preface Vue Router is the official routing manage...

How to Change Colors and Themes in Vim on Linux

Vim is a text editor that we use very often in Li...

Layui implements sample code for multi-condition query

I recently made a file system and found that ther...

Detailed explanation of MySQL delayed replication library method

Simply put, delayed replication is to set a fixed...

HTML adaptive table method

<body style="scroll:no"> <tabl...