After installing MySQL, the root account prompt appears when logging in. mysql ERROR 1045 (28000): Access denied for use solution

After installing MySQL, the root account prompt appears when logging in. mysql ERROR 1045 (28000): Access denied for use solution

After installing MySQL, you will find that the root password is not empty after executing mysql -uroot -p for the first time. To reset the root password, please refer to the following steps.

Edit the MySQL configuration file my.ini (if it is my_default.ini, please rename it to my.ini), and add the following under the [mysqld] entry:

 skip-grant-tables

After saving and exiting, restart MySQL and click "Start" -> "Run" (shortcut key Win+R).

1. Stop: Enter net stop mysql

2. Start: Enter net start mysql

At this time, enter mysql -u root -p in cmd to log in without a password. When password: appears, press Enter to enter. ERROR 1045 (28000) will not appear, but many operations will be restricted because we cannot grant (no permission). Follow the process below:

1. Enter the mysql database:

mysql> use mysql;
Database changed

2. Set a new password for the root user and enter the blue part yourself:

mysql> update user setauthentication_string=password("new password") where user="root";
Query OK, 1 rows affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0

3. Refresh the database

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

4. Exit mysql:

mysql> quit
Bye

After the change, modify the my.ini file again, delete the "skip-grant-tables" line we just added, save and exit, and restart mysql.

You will be prompted after logging in again

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

Just enter set password=password('新密碼');

The above is the solution to the problem that the root account prompts mysql ERROR 1045 (28000): Access denied for use appears after logging in to the newly installed MySql. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

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
  • Solution to the Mysql ERROR 1045 (28000): Access denied for user root@localhost problem in Ubuntu system
  • 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
  • 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

<<:  Two tools for splitting the screen in the Linux command line terminal

>>:  Vue integrates PDF.js to implement PDF preview and add watermark steps

Recommend

How to manually encapsulate paging components in Vue3.0

This article shares the specific code of the vue3...

Vue implements custom "modal pop-up window" component example code

Table of contents Preface Rendering Example Code ...

Detailed explanation of Linux text processing command sort

sort Sort the contents of a text file Usage: sort...

iview implements dynamic form and custom verification time period overlap

Dynamically adding form items iview's dynamic...

Solve the problem of margin merging

1. Merge the margins of sibling elements The effe...

Native js to realize a simple snake game

This article shares the specific code of js to im...

Brief analysis of mysql scheduled backup tasks

Introduction In a production environment, in orde...

Details on using bimface in vue

Table of contents 1. Install Vue scaffolding 2. C...

Vue+webrtc (Tencent Cloud) practice of implementing live broadcast function

Table of contents 1. Live broadcast effect 2. Ste...

Summary of the data storage structure of the nginx http module

Starting from this section, we will explain the i...

Linux RabbitMQ cluster construction process diagram

1. Overall steps At the beginning, we introduced ...

Installation of CUDA10.0 and problems in Ubuntu

The correspondence between tensorflow version and...

Solution to the problem that input in form cannot be submitted when disabled

I wrote a test program before, in which adding and...

Design Story: The Security Guard Who Can't Remember License Plates

<br />In order to manage the vehicles enteri...