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

How to quickly install RabbitMQ in Docker

1. Get the image #Specify the version that includ...

MySQL database case sensitivity issue

In MySQL, databases correspond to directories wit...

How to use MySQL binlog to restore accidentally deleted databases

Table of contents 1 View the current database con...

Mini Program natively implements left-slide drawer menu

Table of contents WXS Response Event Plan A Page ...

About CSS floating and canceling floating

Definition of Float Sets the element out of the n...

Detailed steps for setting up a nexus server

1. The significance of building nexus service As ...

VMware and CentOS system installation method to reset the root password

Today's Tasks 1. Choice of Linux distribution...

Solution to web page confusion caused by web page FOUC problem

FOUC is Flash of Unstyled Content, abbreviated as ...

Centos7 installation of MySQL8 tutorial

MySQL 8 new features: My personal opinion on MySQ...

js date and time formatting method example

js date time format Convert the date and time to ...

A brief discussion on when MySQL uses internal temporary tables

union execution For ease of analysis, use the fol...

Use of docker system command set

Table of contents docker system df docker system ...

react+antd.3x implements ip input box

This article shares the specific code of react+an...

MySQL 8.0.21 installation tutorial under Windows system (illustration and text)

Installation suggestion : Try not to use .exe for...

Linux echo text processing command usage and examples

The description of echo in the Linux help documen...