Ubuntu 简明教程
Ubuntu - Installing MySQL and Python
MySQL 和 Python 分别是著名的数据库和开发软件。它们通常安装在基于 Linux 的系统上。我们来看一下我们如何将它们安装在 Ubuntu 服务器环境中。
MySQL and Python are famous database and development software respectively. These are normally installed on Linux-based systems. Let’s see how we can get them installed on Ubuntu server environments.
Installing Python
首先要做的就是找出系统上安装的 Python 版本。我们可以通过发布以下命令来找到它。
The first thing to do is to find out what is the version of Python installed on the system. We can find this issuing the following command.
Python –v
其中 –v 选项用于说明安装的 Python 版本。下面的屏幕截图显示了上述命令的输出样例。
Where the –v option specifies to show what is the version of Python installed. The following screenshot shows a sample of the output of the above command.

从上面的输出中,我们可以看到安装的 Python 版本是 2.7 版。
From the above output, we can see that the version of Python installed is version 2.7.
还有另一种方法可以通过以下命令查看 Python 是否已安装。
There is another way to see if Python is installed via the following commands.
Python –V
Python3 –V
后一条命令用于查看已安装的 Python 的版本 3。
The later command is used to see the version 3 of Python installed.

如果我们想要安装最新版本的 Python,那么我们需要发布以下声明。
If we want to have the latest version of Python installed, then we need to issue the following statement.
sudo apt-get install python3
上述命令将下载 Python 所需的程序包并安装它。
The above command will download the necessary packages for Python and have it installed.
Installing MySQL
要安装 MySQL,需要执行以下步骤。
To install MySQL, the following steps need to be followed.
Step 1 - 发布 apt-get 命令以确保所有操作系统程序包都是最新的。
Step 1 − Issue the apt-get command to ensure all operating system packages are up to date.
sudo apt-get update

Step 2 - 一旦所有程序包更新完毕,便可获取 MySQL 程序包。
Step 2 − Once all the packages have been updated, it is time to get the packages for MySQL.
sudo apt-get install mysql-server
上述命令将开始下载 MySQL 的所有相关程序包。
The above command will start the download of all the relevant packages for MySQL.
下载完成并开始安装之后,安装程序将首先要求配置根密码。
Once the download completes and the installation starts, the installer will first ask to configure a root password.
Step 3 - 输入所需密码并单击确定按钮。它还将提示重新输入密码。
Step 3 − Enter the required password and click the OK button. It will also prompt to re-enter the password.


Step 4 - 要查看正在运行的 MySQL 进程,请运行以下命令。
Step 4 − To see the MySQL process running, run the following command.
ps –ef | grep mysql
以下屏幕截图显示了 mysqld ,它是在后台运行的 mysql 的守护进程。
The following screenshot shows mysqld which is the daemon process for mysql running in the background.

Step 5 - 要配置 mysql,请运行以下命令。
Step 5 − To configure mysql, run the following command.
/usr/bin/mysql_secure_installation

它会提示输入在安装过程中输入的 root 密码。
It prompts to enter the root password which was entered during the installation process.
Step 6 - 输入密码并按 Enter 键。
Step 6 − Enter the password and hit Enter.
现在,它提示是否要更改 root 密码。
Now, it prompts on whether we want to change the root password.
Step 7 - 输入“N”表示否并继续。
Step 7 − Enter ‘N’ for No and proceed.
它会再次提示是否要删除匿名访问。
Again, it prompts on whether we want to remove the Anonymous access.

Step 8 - 当从其他计算机连接到此数据库时,建议对匿名用户保持默认选项“ N ”,并远程禁止 root 登录。
Step 8 − When connecting from other machines on this database, it is advised to keep the default options as ‘N’ for both anonymous users and disallow root login remotely.

Step 9 - 建议对删除测试数据库的选项也提供 No 选项。我们可以输入“ Y ”来重新加载权限表。
Step 9 − It is advised to provide the option as No for the options of Remove test database as well. We can enter ‘Y’ to reload the privileges table.
最后,MySQL 的配置将完成。
Finally, the configuration of MySQL will be complete.