Solution to the Mysql ERROR 1045 (28000): Access denied for user root@localhost problem in Ubuntu system

Solution to the Mysql ERROR 1045 (28000): Access denied for user root@localhost problem in Ubuntu system

First way:

skip-grant-tables: Very useful mysql startup parameters

Introducing a very useful MySQL startup parameter --skip-grant-tables. As the name implies, it is starting
mysql does not start grant-tables, authorization tables. What's the use? Of course it is useful after you forget the administrator password.

Start mysql with command line parameters: # /usr/bin/mysqld_safe --skip-grant-tables &

3. Change the administrator password:

use mysql;

update user set password=password('yournewpasswordhere') where user='root'; flush privileges; exit;

4. Kill mysql and restart mysql.

Then you can log in directly

Method 2:

View the path where MySQL is installed

Then we change the root user's password,

Check the default password first

Then log in directly

Then change the default root username and password

GRANT ALL PRIVILEGES on *.* to 'root'@'localhost' identified by 'password';
flush privileges;

mysql>update mysql.user set password=password('new password') where User="test" and Host="localhost";

mysql>flush privileges;

mysql>delete from user where User='root' and Host='localhost';

mysql>flush privileges;

mysql>grant select,delete,update,create,drop on *.* to test@"%" identified by "1234";

mysql> UPDATE user SET Host='127.0.0.1' WHERE User='root' AND Host='localhost';

mysql> flush privileges;

Change Grant_priv to 'Y' (flush privileges; (execute this statement or restart MySQL to take effect)), update mysql.user set Grant_priv='Y' where user='ptmind';

You may also be interested in:
  • Solution to mysql ERROR 1045 (28000) problem
  • How to solve the mysql ERROR 1045 (28000)-- Access denied for user problem
  • 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
  • How to solve the problem of error Nr.1045 when installing mysql
  • MySQL ERROR 1045 (28000) error solution
  • MySQL ERROR 1045 (28000): Access denied for user ''root''@''localhost'' (using password: NO) Causes and solutions
  • MySQL login error prompt: Solution to ERROR 1045 (28000)
  • How to solve the ERROR 1045 problem when logging into mysql
  • How to solve Error 1045 access denied when installing MYSQL on winxp
  • MYSQL ERROR 1045 (28000): Access denied for user (using password: YES) solution
  • Solution to ERROR 1054 (42S22) when changing password in MySQL 5.7

<<:  HTML+CSS+JS realizes canvas follows the mouse small circle special effect source code

>>:  Detailed code of the example of downloading the docker installation package from yum and installing it on an offline machine

Recommend

JS+AJAX realizes the linkage of province, city and district drop-down lists

This article shares the specific code of JS+AJAX ...

Analysis of Sysbench's benchmarking process for MySQL

Preface 1. Benchmarking is a type of performance ...

In-depth exploration of whether Mysql fuzzy query is case-sensitive

Preface Recently, I have been busy writing a smal...

How to redirect to https through nginx load balancing

Copy the certificate and key on the web scp -rp -...

Tips for importing csv, excel or sql files into MySQL

1. Import csv file Use the following command: 1.m...

W3C Tutorial (4): W3C XHTML Activities

HTML is a hybrid language used for publishing on ...

How to view version information in Linux

How to view version information under Linux, incl...

Some tips for using less in Vue projects

Table of contents Preface 1. Style penetration 1....

HTML symbol to entity algorithm challenge

challenge: Converts the characters &, <, &...

An enhanced screenshot and sharing tool for Linux: ScreenCloud

ScreenCloud is a great little app you didn’t even...

Detailed explanation of the WeChat applet request pre-processing method

question Because some of our pages request data i...

Native JS to implement sharing sidebar

This article shares a sharing sidebar implemented...

Solution to Element-ui upload file upload restriction

question Adding the type of uploaded file in acce...