How to solve the error when connecting to MySQL in Linux: Access denied for user 'root'@'localhost'(using password: YES)

How to solve the error when connecting to MySQL in Linux: Access denied for user 'root'@'localhost'(using password: YES)

Preface

Recently connected to mysql /usr/local/mysql/bin/mysql -uroot -p

When I enter the password, an error message appears: Access denied for user 'root'@'localhost'(using password: YES) . Let’s take a look at the detailed solution.

Solution:

1. Stop the mysql service first

service mysqld stop 


2. Enter the MySQL installation directory bin/ and use safe mode to restart:

./mysqld_safe --skip-grant-tables 


3. Use the root account, log in without a password, and change the root user password

mysql -u root 
use mysql
update user set password=PASSWORD("your password") where User = 'root';

4. Restart mysql and log in normally

service mysqld restart 


/usr/local/mysql/bin/mysql -uroot -p and then enter the password you just reset

Done, connection successful!

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. If you have any questions, you can leave a message to communicate. Thank you for your support for 123WORDPRESS.COM.

You may also be interested in:
  • 4 solutions to mysql import csv errors
  • Problems and solutions of error 08001 when linking to MySQL in IDEA and no table display after successful connection
  • Problems and solutions for IDEA connecting to MySQL
  • Solution to the problem that synchronous replication errors cannot be skipped in MySQL5.6 GTID mode
  • Solution to ONLY_FULL_GROUP_BY error in Mysql5.7 and above
  • MySQL Error 1290 (HY000) Solution
  • Detailed explanation of the solution to the error in creating a user and granting permissions in mysql8.0
  • Django restarts after reinstalling MySQL and reports an error: How to solve the problem of No module named 'MySQLdb'
  • Solution to the error message "java.sql.SQLException: Incorrect string value:'\xF0\x9F\x92\xA9\x0D\x0A...'" when storing emoticons in MySQL
  • Description and solution of MySQLdb error when installing Python
  • Teach you how to solve the error when storing Chinese characters in MySQL database

<<:  How to install iso file in Linux system

>>:  JavaScript to achieve Taobao product image switching effect

Recommend

A brief understanding of the three uses of standard SQL update statements

1. Environment: MySQL-5.0.41-win32 Windows XP Pro...

Native js to implement form validation function

Table of contents When developing, analyzing the ...

Implementing a simple age calculator based on HTML+JS

Table of contents Preface Demonstration effect HT...

CSS uses calc() to obtain the current visible screen height

First, let's take a look at the relative leng...

MySQL data loss troubleshooting case

Table of contents Preface On-site investigation C...

Completely uninstall mysql. Personal test!

Cleanly uninstall MySQL. Personally tested, this ...

Detailed explanation of destructuring assignment syntax in Javascript

Preface The "destructuring assignment syntax...

js canvas implements verification code and obtains verification code function

This article example shares the specific code of ...

Using JS to implement binary tree traversal algorithm example code

Table of contents Preface 1. Binary Tree 1.1. Tra...

In-depth understanding of MySQL global locks and table locks

Preface According to the scope of locking, locks ...

A MySQL migration plan and practical record of pitfalls

Table of contents background Solution 1: Back up ...

Detailed explanation of soft links and hard links in Linux

Table of contents 1. Basic storage of files and d...

Web page creation for beginners: Learn to use HTML's hyperlink A tag

The hyperlink a tag represents a link point and i...

How to add abort function to promise in JS

Table of contents Overview Promise Race Method Re...

Detailed explanation of built-in methods of javascript array

Table of contents 1. Array.at() 2. Array.copyWith...