brew install MySQL 5.7

Written in front: The blogger is a "little mountain pig" who has devoted himself to training after practical development experience. His nickname is taken from "Peng Peng" in the cartoon "The Lion King". He always treats the surrounding people with an optimistic and positive attitude. thing. My technical route has been from Java full-stack engineer to the field of big data development and data mining. Now I have finally achieved some success. I would like to share with you what I have learned in the past, hoping to be helpful to you on your learning journey. At the same time, the blogger also wants to create a complete technical library through this attempt. Any exceptions, errors, and precautions related to the technical points of the article will be listed at the end. Everyone is welcome to provide materials through various methods.

  • Please criticize and point out any errors in the article and make sure to correct them in time.
  • If you have any questions you want to discuss and learn from, please contact me: [email protected].
  • The style of published articles varies from column to column, and they are all self-contained. Please correct me for any shortcomings.

Homebrew installation of MySQL 5.7 - MacOS

Keywords in this article: MySQL, database, version 5.7, MacOS, Homebrew

Article directory

  • Homebrew installation of MySQL 5.7 - MacOS
    • 1. Introduction to MySQL
    • 2. Version selection
      • 1. Application scenarios
      • 2. MySQL version
    • 3. Installation steps
      • 1. Query software information
      • 2. Execute the installation command
      • 3. Check service status
      • 4. Initial configuration
      • 5. Terminal login test
      • 6. Connection tool test

1. Introduction to MySQL

MySQL is a typical relational database. It is currently one of Oracle's products and one of the mainstream relational databases currently in use. Using MySQL, you can perform the most basic data storage, management, query and other operations. You can also easily set up a database cluster and configure read-write separation.

The MySQL database also uses SQL (Structured Query Language) for operations. At the same time, the MySQL database itself also has many built-in functions that can be used directly. The syntax of some operations will be different from other databases.

2. Version selection

1. Application scenarios

  • Community Edition

During the learning stage, you can use the free community version, which is also a version chosen by small and medium-sized enterprises and can be downloaded directly from the official website. In the community edition, in addition to providing the database server, it also provides community edition related components, such as official visualization tools, MySQL clusters, database drivers for various development languages, etc., which can be downloaded directly as needed.

  • Enterprise Edition

MySQL Enterprise Edition provides commercial solutions. In addition to database services, related products also include: MySQL cloud service, enterprise-level data backup, enterprise-level firewall, enterprise-level data encryption, etc.

2. MySQL version

Currently, the MySQL official website mainly provides support for two major versions: 5.7.x and 8.0.x, but all versions from 5.0.x to the present can still be downloaded. As for why I jumped directly from 5.x to 8.x, I don’t know, but from the information revealed on the official website, we can know that the 8.x version has made major improvements and optimizations in terms of performance compared to the 5.7 version: 2x Faster than MySQL 5.7!

But the author would like to remind everyone here that in the 8.0 MySQL database, some common syntax details have also been adjusted. If you are planning to upgrade, you must pay attention to compatibility issues .
Compared with version 5.6, version 5.7 mainly optimizes performance and provides richer settings. For example, new optimizers, native JSON support, GIS extensions, etc. have been added.

3. Installation steps

Using Homebrew to install the MySQL database requires that the relevant environment has been installed in the MacOS system. For this part, please refer to: Installing Homebrew and Oh-My-Zsh on MacOS . After completion, open the terminal and continue the following operations.

1. Query software information

First use the search command to search for the full name of the MySQL database:

brew search mysql

  
 
  1
 


You can see that the full name of the 5.7 version of the MySQL database is [email protected] .

2. Execute the installation command

Use the install command to install software:

brew install [email protected]

  
 
  1
 


No other operations are required during the installation process, just wait for the installation to complete.

3. Check service status

When installing MySQL for the first time, the service is not turned on. Use the services command to check:

brew services list

  
 
  1
 


Use the start command to start the service. After execution, the service will be automatically started every time the computer is turned on:

brew services start [email protected]

  
 
  1
 

4. Initial configuration

After the installation is complete, you need to perform a configuration before it can be used normally. Execute the following command:

mysql_secure_installation
 

If it prompts that mysql_secure_installation is not found, add the environment variable

  echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
  export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
  export CPPFLAGS="-I/usr/local/opt/[email protected]/include"


If it is for personal use, you can disable the password verification plug-in here , so that we can use a simpler password combination to facilitate memory, so enter n .

  • set password

To set a password for the root user (the highest authority user) of the database, you need to enter it twice. There is no cursor displayed during input, which is normal.

  • Choose whether to remove users

This step can remove unnecessary anonymous users, just enter y and press Enter.

  • Enable remote connection for root user

The default option is not to allow remote connection through the root user, because the root user has the highest authority. It can be turned on during the learning stage to facilitate virtual machine or LAN debugging (if turned on, you need to enter n ).

  • Choose whether to keep the test data set

The installation comes with a test data set by default. You can choose whether to keep it as needed (enter y if you need to remove it ).

  • Refresh permissions now

Enter y to make the password and permission settings take effect immediately, otherwise the database service needs to be restarted.

5. Terminal login test

Test login using the password you just set:

mysql -uroot -p

  
 
  1
 


You can also log in directly using a clear text password in the command, such as (password is root):

mysql -uroot -proot

  
 
  1
 

6. Connection tool test

Taking Navicat as an example, first create a new connection:

fill in the connection name and password to create a new connection:

For an introduction to the basic functions of Navicat, please refer to: MySQL database interface tool - Common functions of Navicat .

Article source: sandtower.blog.csdn.net, author: A Little Mountain Boar, the copyright belongs to the original author. If you need to reprint, please contact the author.

Original link: sandtower.blog.csdn.net/article/details/124556129

Guess you like

Origin blog.csdn.net/asd54090/article/details/133365362