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

One question to understand multiple parameters of sort command in Linux

The sort command is very commonly used, but it al...

JavaScript to implement drop-down list selection box

This article example shares the specific code of ...

Deep understanding of JavaScript syntax and code structure

Table of contents Overview Functionality and read...

Detailed explanation of various usages of proxy_pass in nginx

Table of contents Proxy forwarding rules The firs...

MySQL password modification example detailed explanation

MySQL password modification example detailed expl...

Basic notes on html and css (must read for front-end)

When I first came into contact with HTML, I alway...

CentOs7 64-bit MySQL 5.6.40 source code installation process

1. Install the dependency packages first to avoid...

Research on the effect of page sidebar realized by JS

Table of contents Discover: Application of displa...

Page Refactoring Skills - Javascript, CSS

About JS, CSS CSS: Stylesheet at the top Avoid CS...

HTML Tutorial: Collection of commonly used HTML tags (5)

These introduced HTML tags do not necessarily ful...

Basic steps to use Mysql SSH tunnel connection

Preface For security reasons, the root user of My...

Vue.js framework implements shopping cart function

This article shares the specific code of Vue.js f...