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

How to build MySQL environment under Mac

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

Editor to share with you how to build a MySQL environment under Mac. I hope you will get something after reading this article. Let's discuss it together.

Method 1: install with dmg image

1. Installation

Download the MySQL Mac installation package on the official website and install it in general steps. The following prompts will appear during the installation process:

2019-03-24T18:27:31.043133Z 1 [Note] A temporary password is generated for root@localhost: TdfRm19prago0Xi

Where TdfRm19prago0Xi is the initial password, it is best to remember it first!

2. Log in

Log in to mysql at the terminal command line:

$mysql-u root-p # enter the above password

If this step prompts: bash: mysql: command not found, execute the following two commands to make a soft connection:

Cd / usr/local/binln-fs / usr/local/mysql-8.0.11-macos10.13-x86_64/bin/mysql mysql

3. Change the password

Before MySQL8.0.4, execute SET PASSWORD=PASSWORD ('new password'). But the new version cannot be changed in this way because the password authentication has changed. For more information, please see https://blog.csdn.net/yi247630676/article/details/80352655.

Method 2: install with Homebrew

As we all know, Mac can use homebrew for installation management, which is very convenient. If you don't have homebrew installed, you can click https://brew.sh/ to install.

Here is how mysql is installed

$brew install mysql # install the specified version: brew install mysql@1.1.1

Then all we have to do is wait. After the following words appear, we already know what we need to do:

= > mysqlWe've installed your MySQL database without a root password. To secure it run: mysql_secure_installationMySQL is configured to only allow connections from localhost by defaultTo connect run: mysql-u rootTo have launchd start mysql now and restart at login: brew services start mysqlOr, if you don't want/need a background service you can just run: mysql.server start

Follow the instructions to initialize:

$myysql_secure_installation

There will be many problems in the initialization process. The following is the specific problem section, which is explained by comments:

Would you like to setup VALIDATE PASSWORD component?Press y | Y for Yes, any other key for No: y # # reply y requires more than 8 digits of password, reply n does not restrict The password validation component is not available. Proceeding with the further steps without the component.Please set the password for root here.New password: # # set your password Re-enter new password: # # enter your password By default, a MySQL installation has an anonymous user,allowing anyone to log into MySQL without having to havea user account created for them again. This is intended only fortesting, and to make the installation go a bit smoother.You should remove them before moving into a productionenvironment.Remove anonymous users? (Press y | Y for Yes, any other key for No): whether Y # # removes anonymous users. For security reasons, I chose ySuccess.Normally, root should only be allowed to connect from'localhost'.. This ensures that someone cannot guess atthe root password from the network.Disallow root login remotely? (Press y | Y for Yes, any other key for No): whether Y # # allows remote connection to the root of mysql. I use it for local debugging, not a remote server, so y Success.By default, MySQL comes with a database named 'test' thatanyone can access. This is also intended only for testing,and should be removed before moving into a productionenvironment.Remove test database and access to it? (Press y | Y for Yes, any other key for No): y # # whether y deleted the test database, I chose y-Dropping test database...Success. -Removing privileges on test database...Success.Reloading the privilege tables will ensure that all changesmade so far will take effect immediately.Reload privilege tables now? (Press y | Y for Yes, any other key for No): y # # Select y to reload the permission list Success.All done!

This is the end of the configuration, let's start mysql, remember the following command:

Mysql-u root-p # # log in mysql$ brew services start mysql@5.7 # # start mysql$ brew services stop mysql@5.7 # # stop mysql$ mysql.server start # # start mysql (no backend service) after reading this article, I believe you have some understanding of "how to build a MySQL environment under Mac". If you want to know more about it, welcome to follow the industry information channel, thank you for reading!

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