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

MySQL tutorial DML data manipulation language example detailed explanation

Table of contents 1. Data Manipulation Language (...

Record the whole process of MySQL master-slave configuration based on Linux

mysql master-slave configuration 1. Preparation H...

harborRestart operation after modifying the configuration file

I won't say much nonsense, let's just loo...

Detailed explanation of Vue monitoring attribute graphic example

Table of contents What is the listener property? ...

Processing ideas for decrypting WeChat applet packages on PC in node.js

Table of contents Where is the source code of the...

Detailed explanation of JSON.parse and JSON.stringify usage

Table of contents JSON.parse JSON.parse Syntax re...

A brief introduction to MySQL dialect

Putting aside databases, what is dialect in life?...

CSS style solves the problem of displaying ellipsis when the text is too long

1. CSS style solves the problem of displaying ell...

Improvement experience and sharing of 163 mailbox login box interactive design

I saw in the LOFTER competition that it was mentio...

Let's talk about parameters in MySQL

Preface: In some previous articles, we often see ...

HTML simple shopping quantity applet

This article shares a simple HTML shopping quanti...

Use Navicate to connect to MySQL on Alibaba Cloud Server

1. First enter the server's mysql to modify p...

Recommend a cool flashing alarm button

The effect is as follows: The code is as follows ...

Example method of viewing IP in Linux

Knowing the IP address of a device is important w...