Mysql 简明教程
MySQL - Installation
所有的 MySQL 下载都位于 MySQL Downloads 。选择所需要的 MySQL Community Server 的版本号,以及您将在其上运行它的平台。
All downloads for MySQL are located at MySQL Downloads. Pick the version number of MySQL Community Server which is required along with the platform you will be running it on.
Installing MySQL on Windows
本教程中,我们在 Windows 11 上安装了 MySQL 的最新版本 (8.0.34)。按照以下给定步骤操作 −
In this tutorial, we are installing the latest version of MySQL (8.0.34) on Windows 11. Follow the given steps to do so −
Step 1: 首先,选择 MySQL 版本和操作系统。然后,我们通过单击下图所示的“下载”按钮,在您的系统上下载所需 MSI 安装程序。此安装程序适用于 32 位和 64 位系统。
Step 1: Firstly, choose the MySQL version and operating system. Then, we download the desired MSI installer on your system by clicking the 'Download' button shown in the image below. This installer is suitable for both 32-bit and 64-bit systems.
Step 2: 然后,我们将被重定向到另一个文件下载页面。在此处,忽略要求登录或注册的提示,并直接单击链接开始下载,如图片所示。
Step 2: Then, we will be redirected to another file download page. Here, ignore the prompts asking to log in or sign up and directly start downloading by clicking on the link as shown in the image.
Step 3: 安装程序下载完成后,运行它以开始 MySQL 安装。
Step 3: Once the installer is downloaded, run it to start the MySQL installation.
Step 4: 现在,我们可以看到安装程序社区窗口,要求为我们的 MySQL 产品选择设置类型。选择 Custom 并单击 Next 以确定我们实际上想要安装哪些产品。
Step 4: Now, we can see the installer community window, asking to choose a Setup type for our MySQL products. Choose Custom and click Next to decide what products we want to actually install.
Step 5: 在下一步中,选择要安装的 MySQL 服务器、MySQL Workbench、MySQL Shell(所有最新版本)。我们还可以根据需要选择更多可用的产品。单击 Next 。
Step 5: In the next step, select MySQL Server, MySQL Workbench, MySQL Shell (all latest versions) to be installed. We can also choose more products available as per necessity. Click Next.
Step 6: 现在将开始安装过程。但是,如果存在同名路径目录,可能会出现路径冲突。安装完成后,单击 Next 。
Step 6: The installation process will now begin. However, path conflicts might arise if there exists a path directory with the same name. After the installation is done, click Next.
Step 7: 在此步骤中,系统将要求我们设置 MySQL 的类型和网络。如果没有我们想要进行的任何特定更改,建议保持设置不变,然后单击 Next 。
Step 7: In this step, we will be asked to set Type and Networking of MySQL. Unless there is any particular change we want to make, it is recommended to keep the settings as they are, and click Next.
Next 然后,我们需要设置验证方法以访问 MySQL root 用户。因此,选择强密码加密方法(因为这是推荐的方法),然后单击 Step 8: 。
Step 8: Then, we need to set the Authentication method to access MySQL root user. So, choose the strong password encryption method (as it is recommended) and click Next.
Next 为 root 帐户设置密码。在每次会话中都必须始终使用此密码登录到 root 帐户。设置密码后,单击 Step 9: 。
Step 9: Set a password for the root account. This password must always be used to log into the root account in every session. After setting password, click Next.
Next 在此步骤中,MySQL 服务器实例将配置为 Windows 服务。默认名称将设置为“MySQL80”,可以根据需要进行更改。单击 Step 10: 。
Step 10: In this step, MySQL Server Instance will be configured as a Windows Service. The default name will be set as "MySQL80", which can be changed if needed. Click Next.
Next 现在,根据需要设置文件权限,然后单击 Step 11: 。
Step 11: Now, set the file permissions as required and click Next.
Step 12: 如以下图像所示,单击 Execute 将应用指定的配置步骤。
Step 12: As shown in the image below, the specified configuration steps will be applied on clicking Execute.
完成后,单击 Finish 。下一个窗口将显示已应用配置的产品。单击 Next 完成安装。
Once it is completed, click Finish. The next window will display the products on which the configuration is applied. Click Next to finish the installation.
Step 12: 安装现已完成。取消选中要求在设置后启动 MySQL Workbench 和 Shell 的选项,以便它们在设置后不会运行。单击 Finish 。
Step 12: The installation is now complete. Uncheck the options asking to start MySQL Workbench and Shell after setup, so that they will not run after setup. Click Finish.
MySQL 服务器现已安装在 Windows 操作系统中。我们现在可以通过命令提示符或随其一起安装的 UI 产品(Shell 和 Workbench)访问它。
The MySQL Server is now installed in the Windows Operating System. We can now access it via the Command Prompt or the UI products we installed with it (Shell and Workbench).
Installing MySQL on Linux/UNIX
在 Linux 系统上安装 MySQL 的推荐方法是通过 RPM。MySQL AB 使以下 RPM 可在其网站上下载 −
The recommended way to install MySQL on a Linux system is via RPM. MySQL AB makes the following RPMs available for download on its website −
-
MySQL − The MySQL database server manages the databases and tables, controls user access and processes the SQL queries.
-
MySQL-client − MySQL client programs, which make it possible to connect to and interact with the server.
-
MySQL-devel − Libraries and header files that come in handy when compiling other programs that use MySQL.
-
MySQL-shared − Shared libraries for the MySQL client.
-
MySQL-bench − Benchmark and performance testing tools for the MySQL database server.
此处列出的 MySQL RPM 都是基于一个 SuSE Linux system 构建的,但它们通常可以在其他 Linux 变体上工作,没有困难。
The MySQL RPMs listed here are all built on a SuSE Linux system, but they will usually work on other Linux variants with no difficulty.
现在,你需要遵守以下步骤,以继续安装 −
Now, you will need to adhere to the steps given below, to proceed with the installation −
-
Login to the system using the root user.
-
Switch to the directory containing the RPMs.
-
Install the MySQL database server by executing the following command. Remember to replace the filename in italics with the file name of your RPM.
[root@host]# rpm -i MySQL-5.0.9-0.i386.rpm
上述命令负责安装 MySQL 服务器、创建 MySQL 用户、创建必要的配置并自动启动 MySQL 服务器。
The above command takes care of installing the MySQL server, creating a user of MySQL, creating necessary configuration and starting the MySQL server automatically.
你可以在 /usr/bin 和 /usr/sbin 中找到所有与 MySQL 相关的二进制文件。所有表和数据库都将创建在 /var/lib/mysql 目录中。
You can find all the MySQL related binaries in /usr/bin and /usr/sbin. All the tables and databases will be created in the /var/lib/mysql directory.
以下代码框有一个可选但推荐的步骤,以相同的方式安装其余的 RPM −
The following code box has an optional but recommended step to install the remaining RPMs in the same manner −
[root@host]# rpm -i MySQL-client-5.0.9-0.i386.rpm
[root@host]# rpm -i MySQL-devel-5.0.9-0.i386.rpm
[root@host]# rpm -i MySQL-shared-5.0.9-0.i386.rpm
[root@host]# rpm -i MySQL-bench-5.0.9-0.i386.rpm