liaowenxiongdeMacBook-Air:~ liaowenxiong$ brew install mysql
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/cask).
==> New Casks
avtouchbar breitbandmessung coffitivity-offline letter-opener ultracopier
==> Updated Casks
Updated 127 casks.
==> Deleted Casks
duoshao fraise hessenbox-da iridient-developer juicebar loni-pipeline outwit-hub
elgiganten-jotta gameshow imitone ivideonclient linein masterway-note
evolve-ip-uc-one handylock inxmail-professional jaksta-media-recorder littlesecrets molsoftbrowser
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/icu4c-69.1.big_sur.bottle.tar.gz
######################################################################## 100.0%
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/six-1.16.0_2.all.bottle.1.tar.gz
######################################################################## 100.0%
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/protobuf-3.17.3.big_sur.bottle.tar.gz
######################################################################## 100.0%
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/zstd-1.5.0.big_sur.bottle.tar.gz
######################################################################## 100.0%
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/mysql-8.0.27.big_sur.bottle.tar.gz
######################################################################## 100.0%
==> Installing dependencies for mysql: icu4c, six, protobuf and zstd
==> Installing mysql dependency: icu4c
==> Pouring icu4c-69.1.big_sur.bottle.tar.gz
🍺 /usr/local/Cellar/icu4c/69.1: 259 files, 72.8MB
==> Installing mysql dependency: six
==> Pouring six-1.16.0_2.all.bottle.1.tar.gz
🍺 /usr/local/Cellar/six/1.16.0_2: 20 files, 122.2KB
==> Installing mysql dependency: protobuf
==> Pouring protobuf-3.17.3.big_sur.bottle.tar.gz
🍺 /usr/local/Cellar/protobuf/3.17.3: 210 files, 18.0MB
==> Installing mysql dependency: zstd
==> Pouring zstd-1.5.0.big_sur.bottle.tar.gz
🍺 /usr/local/Cellar/zstd/1.5.0: 31 files, 3.5MB
==> Installing mysql
==> Pouring mysql-8.0.27.big_sur.bottle.tar.gz
==> /usr/local/Cellar/mysql/8.0.27/bin/mysqld --initialize-insecure --user=liaowenxiong --basedir=/usr/local/Cellar/mysql/8.0.27 --datadir=/usr/local/var/mysql --tmpdir=/tmp
==> Caveats
We've installed your MySQL database without a root password. To secure it run:
mysql_secure_installation
MySQL is configured to only allow connections from localhost by default
To connect run:
mysql -uroot
To start mysql:
brew services start mysql
Or, if you don't want/need a background service you can just run:
/usr/local/opt/mysql/bin/mysqld_safe --datadir=/usr/local/var/mysql
==> Summary
🍺 /usr/local/Cellar/mysql/8.0.27: 304 files, 294MB
==> Caveats
==> mysql
We've installed your MySQL database without a root password. To secure it run:
mysql_secure_installation
MySQL is configured to only allow connections from localhost by default
To connect run:
mysql -uroot
To start mysql:
brew services start mysql
Or, if you don't want/need a background service you can just run:
/usr/local/opt/mysql/bin/mysqld_safe --datadir=/usr/local/var/mysql
根据上面的提示,执行下面的命令可以对 MySQL
进行安全配置:
mysql_secure_installation
注意:必须先启动 MySQL
服务才能执行命令 mysql_secure_installation
。
具体执行信息如下:
liaowenxiongdeMacBook-Air:~ liaowenxiong$ brew services start mysql
==> Tapping homebrew/services
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-services'...
remote: Enumerating objects: 1492, done.
remote: Counting objects: 100% (371/371), done.
remote: Compressing objects: 100% (271/271), done.
remote: Total 1492 (delta 150), reused 265 (delta 92), pack-reused 1121
Receiving objects: 100% (1492/1492), 439.39 KiB | 3.30 MiB/s, done.
Resolving deltas: 100% (626/626), done.
Tapped 1 command (38 files, 542.1KB).
==> Successfully started `mysql` (label: homebrew.mxcl.mysql)
liaowenxiongdeMacBook-Air:~ liaowenxiong$ mysql_secure_installation
Securing the MySQL server deployment.
Connecting to MySQL using a blank password.
VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?
Press y|Y for Yes, any other key for No: y
There are three levels of password validation policy:
LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 1
Please set the password for root here.
New password:
Re-enter new password:
Estimated strength of the password: 50
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
... Failed! Error: Your password does not satisfy the current policy requirements
New password:
Re-enter new password:
Estimated strength of the password: 50
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
... Failed! Error: Your password does not satisfy the current policy requirements
New password:
Re-enter new password:
Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : n
... skipping.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done!