How to modify the root user password in mysql 8.0.16 winx64 and Linux

How to modify the root user password in mysql 8.0.16 winx64 and Linux

Please handle basic operations such as connecting to the database by yourself. This article focuses on recording how to change the password.

1. Query user password:

Query user password command:

select host, user, authentication_string from mysql.user;

host: The IP address 'location' that allows users to log in % indicates that it can be remote;

user: the user name of the current database;

authentication_string: user password (this field is mentioned later);

2. Set (or modify) user password:

If the default root password is empty, you will not be able to connect using navicat (it seemed to be OK when I installed 5.7 before), so you need to change the root password here.

This is a crucial step. I was fooled for a long time because of this. Later, I found out after a lot of research that the password field and password() function were deprecated after MySQL 5.7.9.

authentication_string: field indicates the user password.

3. Steps to modify the root password:

1. If there is content under the authentication_string field of the current root user, you can set it to empty first, otherwise proceed directly to step 2.

update user set authentication_string='' where user='root';#The password is set to empty

2. Use ALTER to modify the root user password. The method is ALTER user 'root'@'localhost' IDENTIFIED BY 'new password'. as follows:

alter user 'root'@'%' identified with mysql_native_password by 'xxxx';
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'mypwd#2019';
or alter user 'root'@'localhost' identified with mysql_native_password by 'xxxx';
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'mypwd#2019'

hint:

The content following root@ is the Host field of the user table. The default for a new installation is localhost. Because remote access is added here, localhost is manually changed to %.

After the change, you can execute: flush privileges; (reload the permission table)

flush privileges;

Note: The following method is no longer applicable for versions after MySQL 8.0. Remember! ! !

UPDATE user SET password=PASSWORD("new password") WHERE user='user name';

If there is anything wrong with the above text, please correct it in detail and leave a message to facilitate our common growth in the future;

I hope this blog can be helpful to you!

You may also be interested in:
  • Detailed explanation of the idea of ​​installing mysql8.0.11 and changing the root password and connecting navicat for mysql
  • How to correctly modify the ROOT password in MySql8.0 and above versions
  • Solve the problem of changing the password when logging in for the first time after installing MySQL 8.0
  • Summary of how to modify the root password in MySQL 5.7 and MySQL 8.0
  • MySQL 8.0.19 winx64 installation tutorial and change the initial password under Windows 10
  • MySQL 8.0.12 installation configuration method and password change
  • MySQL 8.0.15 installation and configuration graphic tutorial and password change under Linux
  • Problems with changing password and connecting to Navicat when installing and using MySQL 8.0.16 under Windows 7
  • mysql8.0 forgotten password modification and net command service name invalid problem
  • The correct way to change the password in MySQL 8.0

<<:  How to monitor array changes in JavaScript

>>:  Solution to the problem that docker logs cannot be retrieved

Recommend

JavaScript implementation of a simple addition calculator

This article example shares the specific code of ...

Select web page drop-down list and div layer covering problem

Questions about select elements in HTML have been...

Count the list tags in HTML

1. <dl> defines a list, <dt> defines ...

Detailed explanation of Mysql self-join query example

This article describes the Mysql self-join query....

JavaScript basics of this pointing

Table of contents this Method In the object Hidde...

Practical solution for Prometheus container deployment

environment Hostname IP address Serve Prometheus ...

Basic statements of MySQL data definition language DDL

MySQL DDL statements What is DDL, DML. DDL is dat...

Vue calculated property implementation transcript

This article shares the Vue calculation property ...

foreman ubuntu16 quick installation

Quickstart Guide The Foreman installer is a colle...

Vue implements three-dimensional column chart based on echarts

The three-dimensional column chart consists of th...

Detailed explanation of important cascading concepts in CSS

Recently, I encountered a problem in the process ...

MySQL 4 common master-slave replication architectures

Table of contents One master and multiple slaves ...