MySQL-安装

MySQL-安装 (MySQL - Installation)

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.

MySQL的所有下载均位于MySQL下载中 。 选择所需的MySQL Community Server版本号以及将在其上运行的平台。

在Linux / UNIX上安装MySQL (Installing MySQL on Linux/UNIX)

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 −

建议在Linux系统上安装MySQL的方法是通过RPM。 MySQL AB在其网站上提供了以下RPM可供下载-

  • MySQL − The MySQL database server manages the databases and tables, controls user access and processes the SQL queries.

    MySQL -MySQL数据库服务器管理数据库和表,控制用户访问并处理SQL查询。

  • MySQL-client − MySQL client programs, which make it possible to connect to and interact with the server.

    MySQL客户端 -MySQL客户端程序,可以连接到服务器并与服务器交互。

  • MySQL-devel − Libraries and header files that come in handy when compiling other programs that use MySQL.

    MySQL-devel-编译使用MySQL的其他程序时会派上用场的库和头文件。

  • MySQL-shared − Shared libraries for the MySQL client.

    MySQL共享 -MySQL客户端的共享库。

  • MySQL-bench − Benchmark and performance testing tools for the MySQL database server.

    MySQL-be​​nch -MySQL数据库服务器的基准测试和性能测试工具。

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.

此处列出MySQL RPM都是基于SuSE Linux系统构建的 ,但是它们通常可以毫不费力地在其他Linux变体上运行。

Now, you will need to adhere to the steps given below, to proceed with the installation −

现在,您将需要遵循以下步骤,继续进行安装-

  • Login to the system using the root user.

    使用root用户登录系统。

  • Switch to the directory containing the RPMs.

    切换到包含RPM的目录。

  • Install the MySQL database server by executing the following command. Remember to replace the filename in italics with the file name of your RPM.

    通过执行以下命令来安装MySQL数据库服务器。 请记住用RPM的文件名替换斜体文件名。


[root@host]# rpm -i MySQL-5.0.9-0.i386.rpm

The above command takes care of installing the MySQL server, creating a user of MySQL, creating necessary configuration and starting the MySQL server automatically.

上面的命令负责安装MySQL服务器,创建MySQL用户,创建必要的配置以及自动启动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.

您可以在/ usr / bin和/ usr / sbin中找到所有与MySQL相关的二进制文件。 所有的表和数据库都将在/ var / lib / mysql目录中创建。

The following code box has an optional but recommended step to install the remaining RPMs in the same manner −

以下代码框包含一个可选的但建议执行的步骤,以相同的方式安装其余的RPM-


[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

在Windows上安装MySQL (Installing MySQL on Windows)

The default installation on any version of Windows is now much easier than it used to be, as MySQL now comes neatly packaged with an installer. Simply download the installer package, unzip it anywhere and run the setup.exe file.

现在,在任何Windows版本上的默认安装都比以前容易得多,因为MySQL现在与安装程序打包在一起了。 只需下载安装程序包,将其解压缩到任何地方并运行setup.exe文件即可。

The default installer setup.exe will walk you through the trivial process and by default will install everything under C:\mysql.

默认的安装程序setup.exe将引导您完成整个过程,默认情况下,所有程序都将安装在C:\ mysql下。

Test the server by firing it up from the command prompt the first time. Go to the location of the mysqld server which is probably C:\mysql\bin, and type −

通过在第一次命令提示符下启动服务器来测试服务器。 转到可能是C:\ mysql \ bin的mysqld服务器的位置,然后键入-


mysqld.exe --console

NOTE − If you are on NT, then you will have to use mysqld-nt.exe instead of mysqld.exe

–如果在NT上,则必须使用mysqld-nt.exe而不是mysqld.exe

If all went well, you will see some messages about startup and InnoDB. If not, you may have a permissions issue. Make sure that the directory that holds your data is accessible to whatever user (probably MySQL) the database processes run under.

如果一切顺利,您将看到一些有关startup和InnoDB的消息。 否则,您可能会遇到权限问题。 确保数据库进程所在的任何用户(可能是MySQL)都可以访问保存数据的目录。

MySQL will not add itself to the start menu, and there is no particularly nice GUI way to stop the server either. Therefore, if you tend to start the server by double clicking the mysqld executable, you should remember to halt the process by hand by using mysqladmin, Task List, Task Manager, or other Windows-specific means.

MySQL不会将自己添加到开始菜单中,也没有特别好的GUI方法来停止服务器。 因此,如果您倾向于通过双击mysqld可执行文件来启动服务器,则应记住使用mysqladmin,任务列表,任务管理器或其他Windows专用方法手动停止该过程。

验证MySQL安装 (Verifying MySQL Installation)

After MySQL, has been successfully installed, the base tables have been initialized and the server has been started: you can verify that everything is working as it should be via some simple tests.

成功安装MySQL之后,已初始化基表并启动了服务器:您可以通过一些简单的测试来验证一切是否正常。

使用mysqladmin实用程序获取服务器状态 (Use the mysqladmin Utility to Obtain Server Status)

Use mysqladmin binary to check the server version. This binary would be available in /usr/bin on linux and in C:\mysql\bin on windows.

使用mysqladmin binary检查服务器版本。 该二进制文件将在Linux上的/ usr / bin和Windows上的C:\ mysql \ bin中可用。


[root@host]# mysqladmin --version

It will produce the following result on Linux. It may vary depending on your installation −

在Linux上将产生以下结果。 它可能会因您的安装而异-


mysqladmin  Ver 8.23 Distrib 5.0.9-0, for redhat-linux-gnu on i386

If you do not get such a message, then there may be some problem in your installation and you would need some help to fix it.

如果未收到此消息,则说明您的安装可能存在问题,您将需要一些帮助来修复它。

使用MySQL客户端执行简单SQL命令 (Execute simple SQL commands using the MySQL Client)

You can connect to your MySQL server through the MySQL client and by using the mysql command. At this moment, you do not need to give any password as by default it will be set as blank.

您可以通过MySQL客户端并使用mysql命令连接到MySQL服务器。 目前,您无需提供任何密码,因为默认情况下它将被设置为空白。

You can just use following command −

您可以只使用以下命令-


[root@host]# mysql

It should be rewarded with a mysql> prompt. Now, you are connected to the MySQL server and you can execute all the SQL commands at the mysql> prompt as follows −

应该用mysql>提示符来奖励它。 现在,您已连接到MySQL服务器,并且可以在mysql>提示符下执行所有SQL命令,如下所示-


mysql> SHOW DATABASES;
+----------+
| Database |
+----------+
|   mysql  | 
|   test   |  
+----------+
2 rows in set (0.13 sec)

安装后步骤 (Post-installation Steps)

MySQL ships with a blank password for the root MySQL user. As soon as you have successfully installed the database and the client, you need to set a root password as given in the following code block −

MySQL附带MySQL根用户的空白密码。 成功安装数据库和客户端后,您需要按照以下代码块中的设置设置root密码-


[root@host]# mysqladmin -u root password "new_password";

Now to make a connection to your MySQL server, you would have to use the following command −

现在要建立与MySQL服务器的连接,您将必须使用以下命令-


[root@host]# mysql -u root -p
Enter password:*******

UNIX users will also want to put your MySQL directory in your PATH, so you won't have to keep typing out the full path everytime you want to use the command-line client.

UNIX用户还将希望将MySQL目录放在PATH中,因此您不必每次都要使用命令行客户端时都输入完整路径。

For bash, it would be something like −

对于bash来说,它类似于-


export PATH = $PATH:/usr/bin:/usr/sbin

在启动时运行MySQL (Running MySQL at Boot Time)

If you want to run the MySQL server at boot time, then make sure you have the following entry in the /etc/rc.local file.

如果要在引导时运行MySQL服务器,请确保在/etc/rc.local文件中具有以下条目。


/etc/init.d/mysqld start

Also,you should have the mysqld binary in the /etc/init.d/ directory.

另外,您应该在/etc/init.d/目录中具有mysqld二进制文件。

翻译自: https://www.tutorialspoint.com/mysql/mysql-installation.htm

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值