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

How to deploy Angular project using Docker

There are two ways to deploy Angular projects wit...

An example of how to optimize a project after the Vue project is completed

Table of contents 1. Specify different packaging ...

Vue+ssh framework to realize online chat

This article shares the specific code of Vue+ssh ...

Conflict resolution when marquee and flash coexist in a page

The main symptom of the conflict is that the FLASH...

How to use Flex layout to achieve scrolling of fixed content area in the head

The fixed layout of the page header was previousl...

The Complete List of MIME Types

What is MIME TYPE? 1. First, we need to understan...

Detailed explanation of MySQL 8's new feature ROLE

What problems does MySQL ROLE solve? If you are a...

Detailed explanation of the usage of MySQL memory tables and temporary tables

Usage of MySQL memory tables and temporary tables...

vue-router hook function implements routing guard

Table of contents Overview Global hook function R...

MySQL 8.0.12 installation configuration method and password change

This article records the installation and configu...

Detailed tutorial on uploading and configuring jdk and tomcat on linux

Preparation 1. Start the virtual machine 2. git t...

JavaScript to implement mobile signature function

This article shares the specific code of JavaScri...