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

10 tips for designing useful, easy-to-use web applications

Here are 10 tips on how to design better-usable w...

Version numbers in css and js links in HTML (refresh cache)

background Search the keyword .htaccess cache in ...

Example of using JSX to build component Parser development

Table of contents JSX environment construction Se...

How to write the Nofollow tag and how to use it

The "nofollow" tag was proposed by Goog...

How to operate MySql database with gorm

1. Setting case sensitivity of fields in the tabl...

Example of utf8mb4 collation in MySQL

Common utf8mb4 sorting rules in MySQL are: utf8mb...

Several ways to generate unique IDs in JavaScript

Possible solutions 1. Math.random generates rando...

A simple method to be compatible with IE6's min-width and min-height

If a website is widescreen, you drag the browser ...

Velocity.js implements page scrolling switching effect

Today I will introduce a small Javascript animati...

js, css, html determine the various versions of the browser

Use regular expressions to determine the IE browse...

Detailed explanation of semiotics in Html/CSS

Based on theories such as Saussure's philosop...

Detailed explanation of how to gracefully delete a large table in MySQL

Preface To delete a table, the command that comes...

Pure CSS to achieve the effect of picture blinds display example

First, let me show you the finished effect Main i...

Solution to the Chinese garbled characters problem in MySQL under Ubuntu

Find the problem I have been learning Django rece...