如何在Linux Fedora、CentOS和RedHat中安装Mariadb/Mysql服务器?

马里亚布 一个开源数据库是从另一个流行的开源数据库派生出来的吗 MySQL数据库 . MariaDB开发人员是MySQL的原始开发人员。在甲骨文获得MySQL项目的管理权之后,他们对甲骨文的管理感到不满,开始了MariaDB项目。MariaDB的最新可用版本是10.1.18,但我们会得到我们的发行版提供给我们的。

安装MariaDB

我们将使用 dnf 为了安装MariaDB。该包称为 mariadb-server .

$ sudo dnf install mariadb-server -y

或者我们可以用传统的 yum 包管理器如下所示。

$ sudo yum install mariadb-server -y

用systemctl启动MariaDB数据库服务

在安装了所需的MariaDB包之后,我们将列出MariaDB服务或守护程序的当前状态 systemctl 命令如下。

$ systemctl status mariadb  ● mariadb.service - MariaDB 10.1 database server    Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)    Active: inactive (dead)

现在已停止,我们将启动服务并再次查看状态。

$ sudo systemctl start mariadb  $ sudo systemctl status mariadb ● mariadb.service - MariaDB 10.1 database server    Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)    Active: active (running) since Sun 2016-10-16 02:22:27 UTC; 3s ago   Process: 4775 ExecStartPost=/usr/libexec/mysql-check-upgrade (code=exited, status=0/SUCCESS)   Process: 4587 ExecStartPre=/usr/libexec/mysql-prepare-db-dir %n (code=exited, status=0/SUCCESS)   Process: 4551 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)  Main PID: 4746 (mysqld)    Status: "Taking your SQL requests now..."     Tasks: 26 (limit: 512)    Memory: 191.8M       CPU: 1.306s    CGroup: /system.slice/mariadb.service            └─4746 /usr/libexec/mysqld --basedir=/usr  Oct 16 02:22:27 poftut3 mysql-prepare-db-dir[4587]: See the MariaDB Knowledgebase at http://mariadb.com/kb or the Oct 16 02:22:27 poftut3 mysql-prepare-db-dir[4587]: MySQL manual for more instructions. Oct 16 02:22:27 poftut3 mysql-prepare-db-dir[4587]: Please report any problems at http://mariadb.org/jira Oct 16 02:22:27 poftut3 mysql-prepare-db-dir[4587]: The latest information about MariaDB is available at http://mariadb.org/. Oct 16 02:22:27 poftut3 mysql-prepare-db-dir[4587]: You can find additional information about the MySQL part at: Oct 16 02:22:27 poftut3 mysql-prepare-db-dir[4587]: http://dev.mysql.com Oct 16 02:22:27 poftut3 mysql-prepare-db-dir[4587]: Support MariaDB development by buying support/new features from MariaDB Oct 16 02:22:27 poftut3 mysql-prepare-db-dir[4587]: Corporation Ab. You can contact us about this at [email protected] Oct 16 02:22:27 poftut3 mysqld[4746]: 2016-10-16  2:22:27 140436492912832 [Note] /usr/libexec/mysqld (mysqld 10.1.18-MariaDB) startin Oct 16 02:22:27 poftut3 systemd[1]: Started MariaDB 10.1 database server.

登录MariaDB控制台

我们将登录到 马里亚布 慰问。如前所述,MariaDB从MySQL派生而来,并且大多数工具都与MySQL兼容。为此,我们将使用MySQL数据库管理工具。我们将提供根用户和密码。

$ mysql -u root -p Enter password:  Welcome to the MariaDB monitor.  Commands end with ; or g. Your MariaDB connection id is 2 Server version: 10.1.18-MariaDB MariaDB Server  Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.  Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.  MariaDB [(none)]>

为MariaDB寻求帮助

通过发出help命令,我们可以列出基本命令。

MariaDB [(none)]> h  General information about MariaDB can be found at 
MariaDB Foundation
List of all MySQL commands: Note that all text commands must be first on line and end with ';' ?         (?) Synonym for `help'. clear     (c) Clear the current input statement. connect   ( ) Reconnect to the server. Optional arguments are db and host. delimiter (d) Set statement delimiter. edit      (e) Edit command with $EDITOR. ego       (G) Send command to mysql server, display result vertically. exit      (q) Exit mysql. Same as quit. go        (g) Send command to mysql server. help      (h) Display this help. nopager   () Disable pager, print to stdout. notee     ( ) Don't write into outfile. pager     (P) Set PAGER [to_pager]. Print the query results via PAGER. print     (p) Print current command. prompt    (R) Change your mysql prompt. quit      (q) Quit mysql. rehash    (#) Rebuild completion hash. source    (.) Execute an SQL script file. Takes a file name as an argument. status    (s) Get status information from the server. system    (!) Execute a system shell command. tee       (T) Set outfile [to_outfile]. Append everything into given outfile. use       (u) Use another database. Takes database name as argument. charset   (C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets. warnings  (W) Show warnings after every statement. nowarning (w) Don't show warnings after every statement. For server side help, type 'help contents'

在MariaDB中列出数据库

我们可以用 show databases ; 命令列出MariaDB中的数据库

MariaDB [(none)]> show databases; +--------------------+ | Database           | +--------------------+ | information_schema | | mysql              | | performance_schema | | test               | +--------------------+ 4 rows in set (0.00 sec)

相关文章: 如何从控制台使用Mysql/MariaDB?

如何在Linux Fedora、CentOS和RedHat中安装Mariadb/Mysql服务器?信息图

How to Install Mariadb / Mysql Server in Linux Fedora, CentOS and RedHat? Infografic
如何在Linux Fedora、CentOS和RedHat中安装Mariadb/Mysql服务器?信息图

© 版权声明
THE END
喜欢就支持一下吧,技术咨询可以联系QQ407933975
点赞0
分享