Mariadb 简明教程

MariaDB - Installation

MariaDB 的所有下载都位于官方 MariaDB 基金会网站的 Download 部分。单击你想要的版本的链接,然后会显示一个可用于多个操作系统、体系结构和安装文件类型的下载列表。

All downloads for MariaDB are located in the Download section of the official MariaDB foundation website. Click the link to the version you would like, and a list of downloads for multiple operating systems, architectures, and installation file types is displayed.

Installing on LINUX/UNIX

如果你对 Linux/Unix 系统有深入的了解,只需下载源来构建安装。我们建议的安装方式是使用发行版包。MariaDB 为以下 Linux/Unix 发行版提供包:

If you have intimate knowledge of Linux/Unix systems, simply download source to build your install. Our recommended way of installing is to utilize distribution packages. MariaDB offers packages for the following Linux/Unix distributions −

  1. RedHat/CentOS/Fedora

  2. Debian/Ubuntu

以下发行版在其存储库中包含 MariaDB 包:

The following distributions include a MariaDB package in their repositories −

  1. openSUSE

  2. Arch Linux

  3. Mageia

  4. Mint

  5. Slackware

要在 Ubuntu 环境中安装,请按照以下步骤操作 -

Follow these steps to install in an Ubuntu environment −

Step 1 - 以 root 用户身份登录。

Step 1 − Login as a root user.

Step 2 - 导航到包含 MariaDB 包的目录。

Step 2 − Navigate to the directory containing the MariaDB package.

Step 3 - 使用以下代码导入 GnuPG 签名密钥 -

Step 3 − Import the GnuPG signing key with the following code −

sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db

Step 4 - 将 MariaDB 添加到 sources.list 文件中。打开该文件,并添加以下代码 -

Step 4 − Add MariaDB to the sources.list file. Open the file, and add the following code −

sudo add-apt-repository 'deb http://ftp.osuosl.org/pub/mariadb/repo/5.5/ubuntuprecise main'

Step 5 - 使用以下内容刷新系统 -

Step 5 − Refresh the system with the following −

sudo apt-get update

Step 6 - 使用以下内容安装 MariaDB -

Step 6 − Install MariaDB with the following −

sudo apt-get install mariadb-server

Installing on Windows

在找到并下载自动安装文件 (MSI) 后,只需双击该文件即可开始安装。安装向导将引导您完成安装的每一步和任何必需的设置。

After locating and downloading an automated install file (MSI), simply double click the file to start the installation. The installation wizard will walk you through every step of installation and any necessary settings.

通过从命令提示符启动安装来测试安装。导航到安装位置,通常在该目录中,并在提示符处键入以下内容 -

Test the installation by starting it from the command prompt. Navigate to the location of the installation, typically in the directory, and type the following at the prompt −

mysqld.exe --console

如果安装成功,您将看到与启动相关的消息。如果未显示此消息,您可能存在权限问题。确保您的用户帐户可以访问该应用程序。在 Windows 环境中可用于 MariaDB 管理的图形客户端。如果您觉得命令行不方便或繁琐,请务必尝试使用它们。

If the installation is successful, you will see messages related to startup. If this does not appear, you may have permission issues. Ensure that your user account can access the application. Graphical clients are available for MariaDB administration in the Windows environment. If you find the command line uncomfortable or cumbersome, be sure to experiment with them.

Testing the Installation

执行一些简单任务来确认 MariaDB 的功能和安装。

Perform a few simple tasks to confirm the functioning and installation of MariaDB.

Use the Admin Utility to Get Server Status

Use the Admin Utility to Get Server Status

使用 mysqladmin 二进制文件查看服务器版本。

View the server version with the mysqladmin binary.

[root@host]# mysqladmin --version

它应该显示版本、发行版、操作系统和架构。如果您没有看到该类型的输出,请检查您的安装是否存在问题。

It should display the version, distribution, operating system, and architecture. If you do not see the output of that type, examine your installation for issues.

Execute Simple Commands with a Client

Execute Simple Commands with a Client

调出 MariaDB 的命令提示符。这应该使您连接到 MariaDB 并允许执行命令。输入以下简单命令 -

Bring up the command prompt for MariaDB. This should connect you to MariaDB and allow execution of commands. Enter a simple command as follows −

mysql> SHOW DATABASES;

Post- Installation

成功安装 MariaDB 后,设置 root 密码。新安装的密码将为空。输入以下内容设置新密码 -

After successful installation of MariaDB, set a root password. A fresh install will have a blank password. Enter the following to set the new password −

mysqladmin -u root password "[enter your password here]";

输入以下内容以使用您的新凭据连接到服务器 -

Enter the following to connect to the server with your new credentials −

mysql -u root -p
Enter password:*******

Upgrading on Windows

如果您已经在 Windows 系统上安装了 MySQL,并且想要升级到 MariaDB,请不要卸载 MySQL 并安装 MariaDB。这将与现有数据库产生冲突。相反,您必须安装 MariaDB,然后使用 Windows 安装文件中的升级向导。

If you already have MySQL installed on your Windows system, and want to upgrade to MariaDB; do not uninstall MySQL and install MariaDB. This will cause a conflict with the existing database. You must instead install MariaDB, and then use the upgrade wizard in the Windows installation file.

你的 MySQL my.cnf 文件的选项应与 MariaDB 兼容。但是,MariaDB 有许多 MySQL 中没有的功能。

The options of your MySQL my.cnf file should work with MariaDB. However, MariaDB has many features, which are not found in MySQL.

考虑 my.cnf 文件中的以下冲突——

Consider the following conflicts in your my.cnf file −

  1. MariaDB uses Aria storage engine by default for temporary files. If you have a lot of temporary files, modify key buffer size if you do not use MyISAM tables.

  2. If your applications connect/disconnect frequently, alter the thread cache size.

  3. If you use over 100 connections, use the thread pool.

Compatibility

MySQL 和 MariaDB 基本上是相同的。但是,两者之间有足够的差异会导致升级问题。请参阅 MariaDB Knowledge Base. 中的更多关键差异

MySQL and MariaDB are essentially identical. However, there are enough differences to create issues in upgradation. Review more of these key differences in the MariaDB Knowledge Base.