Solution to forget password when installing MySQL on Linux/Mac

Solution to forget password when installing MySQL on Linux/Mac

Preface

This article mainly introduces the relevant solutions for forgetting the password when installing MySQL on Linux/Mac. It is shared for your reference. Let’s take a look at the detailed introduction.

Use equipment

Computer: Linux or like-Linux OS

mysql version: 5.7+

Problem Description

After the installation is complete, you cannot connect to the database through the command mysql -u root

Solution

Generally, the MySQL server installed through DMG is installed in /usr/local/mysql-version-name-.../

By going into that directory and then cd ./bin

# If mysql is running, shut down the mysql service $ sudo lsof -i:3306
$ sudo kill -9 mysql-pid
# Enable mysql safe mode $ sudo ./mysqld_safe --skip-grant-tables

# Enter mysql shell
$ sudo ./mysql -u root

# Modify the root user password in the mysql.user table $ update mysql.user set authentication_string=PASSWORD('you password') where User='root';

# The modification is complete here.

Afterword

After the modification, if you use navicat to connect to the database, you will be prompted to change the password. Just re-enter the password. Because the password modified through safe mode is still marked as expired, so modify it again.

Summarize

The above is the full content of this article. There are still many shortcomings in this article. I hope that the content of this article will have certain reference learning value for everyone’s 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:
  • The problem of not being able to remember the SVN password of idea under mac and the solution
  • Example code for resetting PostgreSQL password on Mac
  • Solution to the problem that IntelliJ IDEA's SVN cannot save passwords on MAC
  • How to reset mysl8.0.11 password on mac
  • How to set password for mysql version 5.6 on mac
  • Tutorial on resetting the root password of Mac MySQL
  • Solution to forgetting the MYSQL database password under MAC
  • What to do if you forget the initial password when installing MySQL on Mac
  • Common methods for retrieving system account and password on MAC

<<:  VMware Tools installation and configuration tutorial for Ubuntu

>>:  Control the light switch with js

Recommend

Two ways to visualize ClickHouse data using Apache Superset

Apache Superset is a powerful BI tool that provid...

WeChat applet realizes the function of uploading pictures

This article example shares the specific code for...

Detailed explanation of the difference between tags and elements in HTML

I believe that many friends who are new to web pag...

Solution to MySQLSyntaxErrorException when connecting to MySQL using bitronix

Solution to MySQLSyntaxErrorException when connec...

Vue+Element UI realizes the encapsulation of drop-down menu

This article example shares the specific code of ...

A brief discussion of the interesting box model of CSS3 box-sizing property

Everyone must know the composition of the box mod...

Detailed code for implementing 3D tag cloud in Vue

Preview: Code: Page Sections: <template> &l...

How to purchase and initially build a server

I haven't worked with servers for a while. No...

Practical operation of using any font in a web page with demonstration

I have done some research on "embedding non-...

Use the more, less, and cat commands in Linux to view file contents

In Linux, the commands cat, more, and less can al...

uniapp dynamic modification of element node style detailed explanation

Table of contents 1. Modify by binding the style ...

Analysis of MySQL duplicate index and redundant index examples

This article uses examples to describe MySQL dupl...

Linux uses lsof command to check file opening status

Preface We all know that in Linux, "everythi...