Detailed steps to change the default password when installing MySQL in Ubuntu

Detailed steps to change the default password when installing MySQL in Ubuntu

Step 1: Enter the directory: cd /etc/mysql, view the debian.cnf file

Step 2: Log in to MySQL using the account and password in the figure above.

Step 3: View the libraries in the database.

Step 4: Use the mysql library.

Step 5: Use the following statement update user set authentication_string=PASSWORD("自定義新密碼") where user='root';

I personally keep it simple. The account is: root. Password: 123456.

Step 6: Execute the following statement: update user set plugin="mysql_native_password";

Step 7: Refresh: flush privileges;

Step 8: Exit: quit;

Step 9: Password change is complete. In the command box, enter :/etc/init.d/mysql restart; restart MySQL

Last step: log in again. Congratulations, you have successfully changed the default password.

Summarize

The above are the steps for changing the default password of MySQL installed in Ubuntu. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!
If you find this article helpful, please feel free to reprint it and please indicate the source. Thank you!

You may also be interested in:
  • Ubuntu 18.04 does not prompt for password when installing MySQL and how to solve it
  • Solution to forgetting MySQL root password in Ubuntu
  • How to reset mysql server root password in ubuntu

<<:  How to use JS code compiler Monaco

>>:  How to insert a value containing single quotes or backslashes in MySQL statements

Recommend

CenOS6.7 mysql 8.0.22 installation and configuration method graphic tutorial

CenOS6.7 installs MySQL8.0.22 (recommended collec...

Vue uses el-table to dynamically merge columns and rows

This article example shares the specific code of ...

How to prevent hyperlink redirection using JavaScript (multiple ways of writing)

Through JavaScript, we can prevent hyperlinks fro...

The scroll bar position is retained when scrolling the vant list component

The scroll bar position is retained when scrollin...

Detailed explanation of several error handling when Nginx fails to start

When using Nginx as a Web server, I encountered t...

Summary of methods for cleaning Mysql general_log

Method 1: SET GLOBAL general_log = 'OFF';...

JavaScript to achieve all or reverse selection function

This article shares the specific code of JavaScri...

Teach you MySQL query optimization analysis tutorial step by step

Preface MySQL is a relational database with stron...

Vue Element-ui implements tree control node adding icon detailed explanation

Table of contents 1. Rendering 2. Bind data and a...

PHP related paths and modification methods in Ubuntu environment

PHP related paths in Ubuntu environment PHP path ...

XHTML Web Page Tutorial

This article is mainly to let beginners understan...