macos 安装mysql_如何在macOS上安装MySQL
macos 安装mysql_如何在macOS上安装MySQL
macos 安装mysql
On macOS, you can install MySQL easily using Homebrew.
在macOS上,您可以使用Homebrew轻松安装MySQL。
Run:
跑:
brew install mysql
The above command should take a while, then print something like this:
上面的命令应该花一些时间,然后打印如下内容:
You can now start the MySQL server by running:
现在,您可以通过运行以下命令来启动MySQL服务器:
brew services start mysql
Now we need to secure the MySQL server. By default the server comes without a root password, so we need to make sure it’s protected.
现在我们需要保护MySQL服务器。 默认情况下,服务器没有root密码,因此我们需要确保它受到保护。
Run:
跑:
mysql_secure_installation
The procedure can take a while, but it gives a lot of power to make sure you get the best defaults out of the box:
该过程可能会花费一些时间,但是它可以确保您可以立即获得最佳默认设置:
Since we used brew services start mysql to start MySQL, your Mac will re-start it at reboot. You can run:
由于我们使用brew services start mysql来启动MySQL,因此Mac将在重新启动时重新启动它。 您可以运行:
brew services stop mysql
to stop this from happening, and also to immediately stop MySQL.
以阻止这种情况的发生,并立即停止MySQL。
You can also avoid this daemon mode (that’s what we call programs that always run in the background and restart when the computer is restarted) by running:
您还可以通过运行以下命令来避免此守护程序模式 (这就是我们始终在后台运行并在计算机重新启动时重新启动的程序):
mysql.server start
This will start MySQL and will keep it running until the computer is shut down, or until you run:
这将启动MySQL并保持其运行,直到计算机关闭或运行:
mysql.server stop
and it will not re-start it at reboot.
并且它不会在重新启动时重新启动它。
It’s up to you to decide which one you prefer.
由您决定要选择哪一个。
Now you can connect to the server using the command:
现在,您可以使用以下命令连接到服务器:
mysql -u root -p
You will need to type the root user password after you run this command, and once you are done you should see this screen:
您需要输入root在运行此命令后,用户密码,一旦你完成你应该看到这样的画面:
A great GUI (graphical) software we can use to interact with a SQLite database is TablePlus.
TablePlus是我们可以用来与SQLite数据库进行交互的出色GUI(图形)软件。
It comes with a free trial that’s perfect for our usage, because it’s not time-based but rather it limits the amount of concurrent connections you can make to the database.
它带有一个免费试用版,非常适合我们的使用,因为它不是基于时间的,而是限制了您可以与数据库建立的并发连接的数量。
Download it from https://tableplus.com. I know there are macOS, Windows and Linux versions.
从https://tableplus.com下载。 我知道有macOS,Windows和Linux版本。
Click “Create a new connection…” and select MySQL in the list:
单击“创建新连接…”,然后在列表中选择MySQL:
then set a name for the connection, and enter “root” and the password you set previously:
然后为连接设置一个名称,然后输入“ root”和您之前设置的密码:
Click Connect, and you should be connected to MySQL!
单击“ Connect ,您应该已连接到MySQL!
Note that we are connected using the root user, which should only be used for administration purposes.
请注意,我们使用root用户进行连接,该用户只能用于管理目的。
Day to day use of a database should be done using a normal user. We’ll see it in a separate tutorial.
日常使用数据库应该由普通用户完成。 我们将在单独的教程中看到它。
翻译自: https://flaviocopes.com/mysql-how-to-install/
macos 安装mysql
macos 安装mysql_如何在macOS上安装MySQL相关教程