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

How to add Nginx to system services in CentOS7

Introduction After compiling, installing and solv...

Three examples of blur background effects using CSS3

Let’s not start with the introduction and get str...

Solution for adding iptables firewall policy to MySQL service

If your MySQL database is installed on a centos7 ...

mysql code to implement sequence function

MySQL implements sequence function 1. Create a se...

Analyzing ab performance test results under Apache

I have always used Loadrunner to do performance t...

Mysql optimization tool (recommended)

Preface While browsing GitHub today, I found this...

Detailed explanation of the difference between Vue life cycle

Life cycle classification Each component of vue i...

js to implement web calculator

How to make a simple web calculator using HTML, C...

A Deep Dive into the MySQL InnoDB Storage Engine

Preface In MySQL, InnoDB belongs to the storage e...

Vue implements verification whether the username is available

This article example shares the specific code of ...

CSS sets the list style and creates the navigation menu implementation code

1. Set the list symbol list-style-type: attribute...

Programs to query port usage and clear port usage in Windows operating system

In Windows operating system, the program to query...

Detailed explanation of Vue element plus multi-language switching

Table of contents Preface How to switch between m...