How to modify the initial password of MySQL on MAC

How to modify the initial password of MySQL on MAC

Problem description:

I bought a Mac and installed MySQL for the first time. I don’t know the initial password. Please record how to modify the initial password.

Solution:

http://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html

I have tried method 3 and successfully reset my password.

(Thanks @非常, who told me that there is a reset method on the official website. I searched a lot on the Internet...

In addition, step 1 and 2 are from https://www.jb51.net/article/87585.htm

My English is not good, so I don’t quite understand the official one##)

step1:

Apple->System Preferences->Click MySQL at the bottom. In the pop-up page, turn off the MySQL service (click Stop MySQL Server).

step2:

Enter the terminal and enter: cd /usr/local/mysql/bin/

After pressing Enter, log in with administrator privileges sudo su

After pressing Enter, enter the following command to disable the mysql authentication function./mysqld_safe --skip-grant-tables &

After pressing Enter, MySQL will automatically restart (the status of MySQL in the preferences will become running)

step3.

Enter the command ./mysql

After pressing Enter, enter the command FLUSH PRIVILEGES;

After pressing Enter, enter the command SET PASSWORD FOR 'root'@'localhost' = PASSWORD('your new password');

At this point, the password change is complete and you can log in successfully.

2. Others: Basic operations of mysql on mac terminal

First, start the MySQL application manually

Open the terminal and enter the following command: /usr/local/MySQL/bin/mysql -u root -p

( Note: Under Windows, it is: mysql -u root -p)

Here, root is the user name. The following command will appear: Enter password: 123456

This will allow you to access your database server.

   Database Operations

Here are some simple methods from database creation to use;

Create a database named mydatabase:

 create database mydatabase ;

You can use the following command to check whether the database was created successfully:

 show databases ;

Change the database name:

alter databases Hdatabase;

Change the character set of the database mydatabase:

 alter database mydatabase charset GBK ;

Enter the database:

use mydatabase ;

Use the following command to view the tables in the database: show tables;

Table Operations

Use the following command to create the table:

create table student (
          name varchar(10) , 
          gender varchar(10) , 
          sno int primary key(id)
         )charset utf8;

Use the following command to check whether the table is created successfully: show tables;

The above is the method I introduced to you to change the initial password of MySQL on the MAC version. 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!

You may also be interested in:
  • How to change the root password of Mysql5.7.10 on MAC
  • Solution to forgetting MySQL root password in MACOS
  • MySQL initialization password operation under Mac
  • How to solve the problem of forgetting the root password of Mysql on Mac
  • What to do if you forget the initial password of MySQL on MAC
  • What to do if you forget the initial password of MySQL on MAC
  • Solution to forgetting the root password of MySQL5.7 on Mac
  • How to reset mysql password after forgetting it on Mac
  • How to set password for mysql version 5.6 on mac

<<:  Vue form post request combined with Servlet to realize file upload function

>>:  Detailed explanation of docker's high availability configuration

Recommend

Vue project realizes paging effect

The paging effect is implemented in the vue proje...

Solutions to Files/Folders That Cannot Be Deleted in Linux

Preface Recently our server was attacked by hacke...

MySQL multi-instance installation boot auto-start service configuration process

1.MySQL multiple instances MySQL multi-instance m...

Detailed explanation of Javascript event capture and bubbling methods

Table of contents 1. Event Processing Model 1. Ev...

Basic application methods of javascript embedded and external links

Table of contents Basic application of javascript...

Implementation of nested jump of vue routing view router-view

Table of contents 1. Modify the app.vue page 2. C...

XHTML introductory tutorial: Web page Head and DTD

Although head and DTD will not be displayed on th...

Linux process management tool supervisor installation and configuration tutorial

Environment: CentOS 7 Official documentation: htt...

Echarts legend component properties and source code

The legend component is a commonly used component...

...

Summary of HTML formatting standards for web-based email content

1. Page requirements 1) Use standard headers and ...