Method of Modifying MySQL Initial Password in MAC Edition

  • 2021-07-03 01:00:05
  • OfStack

Problem description:

I bought an mac computer and installed mysql for the first time. I don't know the initial password. How to modify the initial password is recorded.

Solution:

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

Pro-test method 3, the password has been successfully reset.

(Thank you @ very, tell me there is a reset method in official website, and I searched 1 pile on the Internet...

In addition, step1 and 2 are from https://www.ofstack.com/article/87585. htm

English is not good, and the official one doesn't quite understand # #)

step1:

Apples-- > System Preferences- > The bottom point mysql closes the mysql service in the pop-up page (click stop mysql server)

step2:

Enter terminal input: cd/usr/local/mysql/bin/

Login Administrator Permission after Enter sudo su

Enter to disable the mysql authentication function./mysqld_safe-skip-grant-tables &

mysql will restart automatically after carriage return (the status of mysql in preferences will change to running)

step3.

Enter commands./mysql

Enter the command FLUSH PRIVILEGES;

Enter and enter the command SET PASSWORD FOR 'root' @ 'localhost' = PASSWORD ('Your New Password');

At this point, the password modification is completed and you can log in successfully.

2. Others: mac terminal basic operation mysql

Start the MySQL application manually

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

(Note: mysql-u root-p under Windows)

Where root is the user name. The following command appears: Enter password: 123456

So you can access your database server.

Database operation

Here are some simple methods from database creation to use.

Create a database named mydatabase:


 create database mydatabase ;

You can use the following commands to see if the database was created successfully:


 show databases ;

Change the database name:


alter databases Hdatabase ;

Change the character set of database mydatabase:


 alter database mydatabase charset GBK ;

Access the database:


use mydatabase ;

View the tables in the database with the following command: show tables;

Table operation

Create the table with the following command:


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

Check whether the table was created successfully with the following command: show tables;


Related articles: