Detailed installation and configuration of MySql on Mac

Detailed installation and configuration of MySql on Mac

1. Download and install

Download the community edition dmg installation file from the official website: https://dev.mysql.com/downloads/mysql/

1. Execute the installation file and follow the steps to complete the installation.

2. After the installation is complete, enter the following in the terminal:

mysql --version;

----If the version number is displayed, it is normal. If it displays command not found, enter the following in the terminal. "/usr/local/mysql/bin/mysql" is the default installation path of MySQL:

$ cd /usr/local/bin/
$ sudo ln -fs /usr/local/mysql/bin/mysql mysql

3. Shut down the mysql service:

sudo /usr/local/mysql/support-files/mysql.server stop

2. Environment variable configuration

1. Open the terminal and enter:

cd ~

Will enter the ~ folder

2. Then enter:

touch .bash_profile

After pressing Enter,

3. Then input:

open -e .bash_profile

This file will open in TextEdit (if you have not configured environment variables before, this should be a blank document). If there is content, please enter it before the end character. If there is no content, please enter the following statement directly:

export PATH=${PATH}:/usr/local/mysql/bin

Then, save, exit TextEdit (be sure to exit), close the terminal and exit.

3. Forgot root password reset

1. Apple->System Preferences->Stop MySQL service (click stop MySQL server)

2. Enter the terminal and input:

cd /usr/local/mysql/bin/

After pressing Enter, log in as administrator

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)

3. Enter the command

./mysql

After pressing Enter, enter the command

FLUSH PRIVILEGES;

After pressing Enter, enter the command

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123');

The modification is now complete. After restarting the terminal, enter mysql -u root -p, press Enter, and then enter the password: 123 to start successfully.

4. Delete

Stop the MySql process and enter the following command in the console.

sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
vim /etc/hostconfig (and removed the line MYSQLCOM=-YES-)
rm -rf ~/Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /var/db/receipts/com.mysql.*

The above is the detailed installation and configuration of MySql on Mac introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor 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:
  • MySQL5.7+ MySQL Workbench installation and configuration method graphic tutorial under MAC
  • MySQL 8.0.11 MacOS 10.13 installation and configuration method graphic tutorial
  • Download MySQL 5.7 and detailed installation diagram for MySql on Mac
  • What to do if you forget the initial password when installing MySQL on Mac
  • Complete steps to install mysql5.7 on Mac (with pictures and text)
  • Mac installation mysqlclient process analysis

<<:  Vue simple implementation of turntable lottery

>>:  Solve the problem of regular automatic file deletion by crontab+shell script under Centos7

Recommend

Web page printing thin line table + page printing ultimate strategy

When I was printing for a client recently, he aske...

JS interview question: Can forEach jump out of the loop?

When I was asked this question, I was ignorant an...

MySQL database implements MMM high availability cluster architecture

concept MMM (Master-Master replication manager fo...

Table Tag (table) In-depth

<br />Table is a tag that has been used by e...

MySQL randomly extracts a certain number of records

In the past, I used to directly order by rand() t...

Introduction to general_log log knowledge points in MySQL

The following operation demonstrations are all ba...

JS Object constructor Object.freeze

Table of contents Overview Example 1) Freeze Obje...

Detailed explanation of CSS3 rotating cube problem

3D coordinate concept When an element rotates, it...

Specific usage of Vue's new toy VueUse

Table of contents Preface What is VueUse Easy to ...

Docker case analysis: Building a Redis service

Table of contents 1 Create mount directories and ...

Solve the problem of Docker starting Elasticsearch7.x and reporting an error

Using the Docker run command docker run -d -p 920...

MySQL 20 high-performance architecture design principles (worth collecting)

Open Source Database Architecture Design Principl...