Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the steps to install MYSQL on MAC

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "what are the steps to install MYSQL on MAC". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what are the steps to install MYSQL on MAC".

How does MAC install MYSQL?

Download address: https://downloads.mysql.com/archives/community/

Baidu network disk download: link: https://pan.baidu.com/s/1nceFzJKK7_dJh3gUAtVgWw password: qm5z

Installation

Double-click the downloaded dmg file, the pkg pop-up box will pop up, and then double-click the pkg icon to enter the installation interface, continue all the way in the installation interface, and the installation will be successful.

Environment variable

The first step is to change to the root directory at the terminal and edit the. / .bash _ profile file

➜~ cd ~➜ ~ vim. / .bash _ profile

The second step is to enter the vim editing environment, press I to enter insert mode, type

Export PATH=$PATH:/usr/local/mysql/binexport PATH=$PATH:/usr/local/mysql/support-files

Third, press esc to exit insert mode and enter: wq to save the configuration file

: wq

In the fourth step, enter the following command in the terminal interface to make the changes to the configuration file take effect, and check whether the environment variable is set successfully.

➜~ echo $PATH/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin➜ ~ source ~ / .bash_profile ➜~ echo $PATH/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin: / usr/local/mysql/bin:/usr/local/mysql/support-files➜ ~ View of the start, stop and status of the service

View the service status of MYSQL

➜~ sudo mysql.server statusPassword: ERROR! MySQL is not running

Start the MYSQL service

➜~ sudo mysql.server start Starting MySQL.Logging to'/ usr/local/mysql/data/mj.local.err'. SUCCESS!

Stop the MYSQL service

➜~ sudo mysql.server stop Shutting down MySQL. SUCCESS!

Restart the MYSQL service

➜~ sudo mysql.server restart ERROR! MySQL server PID file could not be found!Starting MySQL. SUCCESS! Start

The first step is to enter under the terminal interface.

➜~ sudo mysql.server start Starting MySQL.Logging to'/ usr/local/mysql/data/mj.local.err'. SUCCESS!

The second step is to start the MYSQL service, and continue typing after starting successfully.

➜~ mysql-u root-p

The third step is to enter directly, enter the database, and see the following welcome screen

Enter password: Welcome to the MySQL monitor. Commands end with; or\ g.Your MySQL connection id is 1Server version: 5.6.41 MySQL Community Server (GPL) Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.mysql >

Note: by default, there is no initial password after successful installation, so the password does not need to be entered, just enter.

Initialization Settin

Set the initial password. After entering the mysql database, execute the following statement to set the password of the current root user to root

➜~ mysql-u root-pEnter password: Welcome to the MySQL monitor. Commands end with; or\ g.Your MySQL connection id is 2Server version: 5.6.41 MySQL Community Server (GPL) Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.mysql > set password = password ('root'); Query OK, 0 rows affected (0.01 sec) mysql >

Exit the interface of MYSQL

Mysql > exitBye ➜~ configuration

Go to the / usr/local/mysql/support-files directory, where there is a file my-default.cnf

➜~ cd / usr/local/mysql/support-files➜ support-files lltotal 64-rwxr-xr-x 1 root wheel 1.1K 6 15 2018 binary-configure-rw-r--r-- 1 root wheel 773B 6 15 2018 magic-rw-r--r-- 1 root wheel 1.1K 6 15 2018 my-default.cnf-rwxr-xr-x 1 root wheel 894B 6 15 2018 mysql-log-rotate-rwxr-xr-x 1 root wheel 10K 6 15 2018 mysql.server -rwxr-xr-x 1 root wheel 1.0K 6 15 2018 mysqld_multi.server ➜support-files

Copy the my-default.cnf file in the directory to the desktop and rename it my.cnf

➜support-files lltotal 64-rwxr-xr-x 1 root wheel 1.1K 6 15 2018 binary-configure-rw-r--r-- 1 root wheel 773B 6 15 2018 magic-rw-r--r-- 1 root wheel 1.1K 6 15 2018 my-default.cnf-rwxr-xr-x 1 root wheel 894B 6 15 2018 mysql-log-rotate-rwxr-xr-x 1 root wheel 10K 6 15 2018 mysql.server-rwxr-xr-x 1 root wheel 1.0K 6 15 2018 mysqld_multi.server ➜support-files cp my-default.cnf / Users/a1/Desktop/my.cnf

Replace the content with the following

[mysqld] default-storage-engine=INNODBcharacter-set-server=utf8port = 3306 [client] default-character-set=utf8

Copy the modified my.cnf file to the / etc directory and restart MYSQL

➜/ etc cp / Users/a1/Desktop/my.cnf. / cp:. / my.cnf: Permission denied➜ / etc sudo cp / Users/a1/Desktop/my.cnf. / Password: ➜/ etc lltotal 1064.When RW-1 root wheel 7.3K 2 29 14:10 master.passwd-rw-r--r-- 1 root wheel 1.2K 5 17 17:24 my.cnf-rw-r--r-- 1 root wheel 11B 2 29 14:43 nanorc-rw-r--r-- 1 root wheel 53B 2 29 14:09 networks. ➜/ etc

Note: system permissions are required to copy files to the etc directory, so you need to add sudo before the command

Detect the result of modification

➜~ mysql-u root-pEnter password: Welcome to the MySQL monitor. Commands end with; or\ g.Your MySQL connection id is 4Server version: 5.6.41 MySQL Community Server (GPL) Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.mysql > show variables like'% char%' +-- +-- + | Variable_name | Value | | +-- +-- + | character_set_client | utf8 | | | character_set_connection | utf8 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | utf8 | | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | / usr/local/mysql-5.6.41-macos10.13 | -x86_64/share/charsets/ | +-- +-+ 8 rows in set (0.01sec) mysql >

Note: at this time, you cannot log in to the database without entering a password, you must use the modified password to log in to the database, and the character set coding information of the database has been modified.

Thank you for your reading, the above is the content of "what are the steps for installing MYSQL on MAC". After the study of this article, I believe you have a deeper understanding of what the steps of installing MYSQL on MAC are, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report