设为首页 加入收藏

TOP

MySQL入门——在Linux下安装和卸载MariaDB(一)
2019-09-17 15:48:54 】 浏览:23
Tags:MySQL 入门 Linux 安装 卸载 MariaDB

MySQL入门——在Linux下安装和卸载MariaDB

摘要:本文主要学习了如何在Linux系统中安装和卸载MariaDB数据库。

查看有没有安装过MariaDB

使用命令查看有没有安装过:

1 [root@localhost ~]# yum list installed | grep mariadb
2 mariadb-libs.x86_64                   1:5.5.44-2.el7.centos            @anaconda
3 [root@localhost ~]# 

使用的系统是CentOS版本是7.2.1511,可以看到系统只是安装了用到的libs包,并没有安装MariaDB的服务端和客户端。

安装MariaDB

安装

使用命令安装:

 1 [root@localhost ~]# yum install -y mariadb mariadb-server
 2 已加载插件:fastestmirror
 3 Loading mirror speeds from cached hostfile
 4  * base: mirrors.huaweicloud.com
 5  * extras: mirrors.huaweicloud.com
 6  * updates: mirrors.huaweicloud.com
 7 正在解决依赖关系
 8 --> 正在检查事务
 9 ...
10 完毕!
11 [root@localhost ~]#

使用命令查看安装的程序:

1 [root@localhost ~]# yum list installed | grep mariadb
2 mariadb.x86_64                        1:5.5.60-1.el7_5                 @base    
3 mariadb-libs.x86_64                   1:5.5.60-1.el7_5                 @base    
4 mariadb-server.x86_64                 1:5.5.60-1.el7_5                 @base    
5 [root@localhost ~]# 

启动服务

查看MariaDB的状态:

1 [root@localhost ~]# systemctl status mariadb
2 ● mariadb.service - MariaDB database server
3    Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
4    Active: inactive (dead)
5 [root@localhost ~]#

启动MariaDB并查看MariaDB的状态:

 1 [root@localhost ~]# systemctl start mariadb
 2 [root@localhost ~]# systemctl status mariadb
 3 ● mariadb.service - MariaDB database server
 4    Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
 5    Active: active (running) since 六 2019-07-13 05:19:08 CST; 36s ago
 6   Process: 4162 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=0/SUCCESS)
 7   Process: 4082 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
 8  Main PID: 4161 (mysqld_safe)
 9    CGroup: /system.slice/mariadb.service
10            ├─4161 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
11            └─4323 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socke...
12 ...
13 [root@localhost ~]#

连接数据库

连接并查看版本:

 1 [root@localhost ~]# mysql -uroot
 2 Welcome to the MariaDB monitor.  Commands end with ; or \g.
 3 Your MariaDB connection id is 2
 4 Server version: 5.5.60-MariaDB MariaDB Server
 5 
 6 Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
 7 
 8 Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 9 
10 MariaDB [(none)]> select version();
11 +----------------+
12 | version()      |
13 +----------------+
14 | 5.5.60-MariaDB |
15 +----------------+
16 1 row in set (0.00 sec)
17 
18 MariaDB [(none)]>

退出:

1 MariaDB [(none)]> exit
2 Bye
3 [root@localhost ~]#

简单配置

使用命令对MariaDB进行简单配置:

1 [root@localhost ~]# mysql_secure_installation
2 
3 NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
4       SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

输入当前的密码,如果没有设置就回车:

1 In order to log into MariaDB to secure it, we'll need the current
2 password for the root user.  If you've just installed MariaDB, and
3 you haven't set the root password yet, the password will be blank,
4 so you should just press enter here.
5 
6 Enter current password for root (enter for none): 
7 OK, successfully used password, moving on...

是否为root用户设置密码:

1 Setting the root password ensures that nobody can log into the Mari
首页 上一页 1 2 下一页 尾页 1/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇AWS Aurora数据库 Multi-Master .. 下一篇Flink+Druid构建实时OLAP的探索

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目