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

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

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

查看有没有安装过MariaDB

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

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

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

安装MariaDB

安装

使用命令安装:

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

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

11 [root@localhost ~]# yum list installed | grep mariadb 22 mariadb.x86_64 1:5.5.60-1.el7_5 @base 33 mariadb-libs.x86_64 1:5.5.60-1.el7_5 @base 44 mariadb-server.x86_64 1:5.5.60-1.el7_5 @base 55 [root@localhost ~]#

启动服务

查看MariaDB的状态:

11 [root@localhost ~]# systemctl status mariadb 22 ● mariadb.service - MariaDB database server 33 Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled) 44 Active: inactive (dead) 55 [root@localhost ~]#

启动MariaDB并查看MariaDB的状态:

1 1 [root@localhost ~]# systemctl start mariadb 2 2 [root@localhost ~]# systemctl status mariadb 3 3 ● mariadb.service - MariaDB database server 4 4 Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled) 5 5 Active: active (running) since 六 2019-07-13 05:19:08 CST; 36s ago 6 6 Process: 4162 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=0/SUCCESS) 7 7 Process: 4082 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS) 8 8 Main PID: 4161 (mysqld_safe) 9 9 CGroup: /system.slice/mariadb.service 1010 ├─4161 /bin/sh /usr/bin/mysqld_safe --basedir=/usr 1111 └─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... 1212 ... 1313 [root@localhost ~]#

连接数据库

连接并查看版本:

1 1 [root@localhost ~]# mysql -uroot 2 2 Welcome to the MariaDB monitor. Commands end with ; or \g. 3 3 Your MariaDB connection id is 2 4 4 Server version: 5.5.60-MariaDB MariaDB Server 5 5 6 6 Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. 7 7 8 8 Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. 9 9 1010 MariaDB [(none)]> select version(); 1111 +----------------+ 1212 | version() | 1313 +----------------+ 1414 | 5.5.60-MariaDB | 1515 +----------------+ 1616 1 row in set (0.00 sec) 1717 1818 MariaDB [(none)]>

退出:

11 MariaDB [(none)]> exit 22 Bye 33 [root@localhost ~]#

简单配置

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

11 [root@localhost ~]# mysql_secure_installation 22 33 NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB 44 SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

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

11 In order to log into MariaDB to secure it, we'll need the current 22 password for the root user. If you've just installed MariaDB, and 33 you haven't set the root password yet, the password will be blank, 44 so you should just press enter here. 55 66 Enter current password for root (enter for none): 77 OK, successfully used password, moving on...

是否为root用户设置密码:

11 Setting the root password ensures that nobody can log into the MariaDB 22 root user without the proper authorisation. 33 44 Set root password? [Y/n] Y 55 New password: 66 Re-enter new password: 77 Password updated successfully! 88 Reloading privilege tables.. 99 ... Success!

是否删除匿名用户:

11 By default, a MariaDB installation has an anonymous user, allowing anyone 22 to log into MariaDB without having to have a user account created for 33 them. This is intended only for testing, and to make the installation 44 go a bit smoother. You should remove them before moving into a 55 production environment. 66 77 Remove anonymous users? [Y/n] 88 ... Success!

是否允许root用户远程登录:

11 Normally, root should only be allowed to connect from 'localhost'. This 22 ensures that someone cannot guess at the root password from the network. 33 44 Disallow root login remotely? [Y/n] 55 ... Success!

是否删除test数据库:

11 By default, MariaDB comes with a database named 'test' that anyone can 22 access. This is also intended only for testing, and should be removed 33 before moving into a production environment. 44 55 Remove test database and access to it? [Y/n] 66 - Dropping test database... 77 ... Success! 88 - Removing privileges on test database... 99 ... Success!

是否重新加载权限表:

11 Reloading the privilege tables will ensure that all changes made so far 22 will take effect immediately. 33 44 Reload privilege tables now? [Y/n] 55 ... Success!

设置完成:

11 Cleaning up... 22 33 All done! If you've completed all of the above steps, your MariaDB 44 installation should now be secure. 55 66 Thanks for using MariaDB! 77 [root@localhost ~]#

卸载MariaDB

使用命令卸载安装包:

11 [root@localhost ~]# yum remove -y mariadb-libs 22 已加载插件:fastestmirror 33 正在解决依赖关系 44 --> 正在检查事务 55 ... 66 完毕! 77 [root@localhost ~]#

查看卸载后的安装情况:

11 [root@localhost ~]# yum list installed | grep mariadb 22 [root@localhost ~]#

表明已经从系统中卸载了。

点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

皕杰报表之UUID

​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为

2020年前端实用代码段,为你的工作保驾护航

有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )

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

MySQL入门——在Linux下安装和卸载MySQL摘要:本文主要学习了如何在Linux系统中安装和卸载MySQL数据库。查看有没有安装过MySQL使用命令查看有没有安装过:1root@localhost~yumlistinstalled