【软件安装】CentOS7安装MariaDb(mysql_替代品安装)

摘要:
建议安装VM+CentOS,并尝试$指示系统的常规权限。但是,您可以通过修改/etc/my.cnf中的绑定地址参数来更改它侦听的地址。disabled)Active:Active(正在运行)sinceWed2019-05-0815:status=0/SSUCCESS)Process:status=0/SUCCCESS)MainPID:

1、背景

Maria Db是流行的跨平台MySQL数据库管理系统的分支,被认为是MySQL 的完全替代品。Maria Db是由Sun在Sun Micro systems合并期间被Oracle收购后,于2009年由MySQL的一位原始开发人员创建的。今天,Maria Db由Maria Db Foundation和社区贡献者维护和开发,
Maria Db将MySQL替换为Cent OS 7存储库中的默认数据库系统。虽然将MySQL安装到Cent OS 7并不困难,但是如果您只需要一个数据库,建议使用Maria Db进行官方支持,并且与其他存储库软件不兼容的可能性很小。

2、开始之前

  • 虚拟机是最好的伙伴,推荐安装一个VM+CentOS 自己动手试试
$ 表示系统的一般权限,不用使用root 超级管理员权限配置。
要检查您的主机名:
$ hostname -f
$ hostname

img

1.1 安装开始

  • 第一个命令应显示您的短主机名,第二个命令应显示您的完全限定域名(FQDN)。

  • 更新您的系统:

$ sudo yum update
  • 安装并启动MariaDB
$ sudo yum install mariadb-server
  • 启用MariaDB以在启动时启动,然后启动该服务:
systemctl start mariadb
systemctl status mariadb
systemctl enable mariadb
  • 默认情况下,MariaDB将绑定到localhost(127.0.0.1)。

注意

允许在公共IP上不受限制地访问MariaDB,但是您可以在/etc/my.cnf中通过修改bind-address参数来更改它侦听的地址。如果您决定将MariaDB绑定到公共IP,则应实施仅允许来自特定IP地址连接的防火墙规则。

[root@centos001 ~]# systemctl start mariadb
[root@centos001 ~]# systemctl status mariadb
● mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
   Active: active (running) since Wed 2019-05-08 15:23:10 CST; 14s ago
  Process: 13148 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=0/SUCCESS)
  Process: 13069 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
 Main PID: 13147 (mysqld_safe)
   CGroup: /system.slice/mariadb.service
           ├─13147 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
           └─13309 /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...

May 08 15:23:08 centos001 mariadb-prepare-db-dir[13069]: MySQL manual for more instructions.
May 08 15:23:08 centos001 mariadb-prepare-db-dir[13069]: Please report any problems at http://mariadb.org/jira
May 08 15:23:08 centos001 mariadb-prepare-db-dir[13069]: The latest information about MariaDB is available at http://mariadb.org/.
May 08 15:23:08 centos001 mariadb-prepare-db-dir[13069]: You can find additional information about the MySQL part at:
May 08 15:23:08 centos001 mariadb-prepare-db-dir[13069]: http://dev.mysql.com
May 08 15:23:08 centos001 mariadb-prepare-db-dir[13069]: Consider joining MariaDB's strong and vibrant community:
May 08 15:23:08 centos001 mariadb-prepare-db-dir[13069]: https://mariadb.org/get-involved/
May 08 15:23:08 centos001 mysqld_safe[13147]: 190508 15:23:08 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
May 08 15:23:08 centos001 mysqld_safe[13147]: 190508 15:23:08 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
May 08 15:23:10 centos001 systemd[1]: Started MariaDB database server.
[root@centos001 ~]#


 

1.2 最后检测

安装完成之后,运行一下命令,进入数据库,默认不需要密码
$ mysql -uroot -p

 img

 - 查询数据库列表

[root@centos001 ~]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or g.
Your MariaDB connection id is 13
Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

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

MariaDB [(none)]>
 

img

安装到此结束,余下是介绍如何使用配置


3、初始化配置,MariaDB的相关简单配置

  • 接下来进行
$  mysql_secure_installation
  • 首先是设置密码,会提示先输入密码
Enter current password for root (enter for none):<–初次运行直接回车
  • 设置密码
Set root password? [Y/n] <– 是否设置root用户密码,输入y并回车或直接回车
New password: <– 设置root用户的密码
Re-enter new password: <– 再输入一次你设置的密码
  • 其他配置
Remove anonymous users? [Y/n] <– 是否删除匿名用户,回车
Disallow root login remotely? [Y/n] <–是否禁止root远程登录,Y 回车,
Remove test database and access to it? [Y/n] <– 是否删除test数据库, N回车
Reload privilege tables now? [Y/n] <– 是否重新加载权限表,Y 回车

  • 我的设置,设置错了再来一次

img

初始化MariaDB完成,接下来测试登录,输入一下命令和密码 登录进去

$ mysql -u root -p 

img

4、操作不会请输入Help

要为MariaDB提示生成命令列表,请输入h。然后你会看到:


   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 [(none)]>

5 重置MariaDB Root密码

** 如果您忘记了root 密码,则可以重置密码。**

  • 停止当前的MariaDB服务器实例,然后使用不要求输入密码的选项重新启动它:
   sudo systemctl stop mariadb
   sudo mysqld_safe --skip-grant-tables &
  • 使用MariaDB root帐户重新连接到MariaDB服务器:
   mysql -u root
  • 使用以下命令重置root的密码。用强密码替换password
   use mysql;
   update user SET PASSWORD=PASSWORD("password") WHERE USER='root';
   flush privileges;
   exit
  • 然后重启MariaDB:
   sudo systemctl start mariadb

免责声明:文章转载自《【软件安装】CentOS7安装MariaDb(mysql_替代品安装)》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇CAS服务器集群和客户端集群环境下的单点登录和单点注销解决方案Android集成友盟facebook分享下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

Python3.7源码包编译安装

环境: [root@localhost python3]# cat /etc/redhat-release CentOS Linux release 7.5.1804 (Core) [root@localhost python3]# 1、下载Python 方式一: 进入 https://www.python.org/downloads/sourc...

FastDFS安装

FastDFS 安装包 FastDFS安装包 百度网盘 密码 aj4f 下载后把安装包移动到服务器里面 这里我把安装包放在opt/FastDFS FastDFS安装 安装环境 在本地安装就需要安装gcc环境yum -y install cmake make gcc-c++ 在阿里服务器因为帮你配置好了的 解压libfastcommon到指定目录 解压 -C...

Mysql 主从复制

mysql主从复制好处:1. 如果是单个数据库,如果挂了就凉凉2.主备数据库,挂了一台主库,我可能还有很多个备用的数据库2,读和写分开,减少了数据库的压力 实验准备:主机一(主) : 192.168.11.70主机二(从): 192.168.11.224都装有Mariadb 第一步-主机的操作: 1.在matser主库上的操作,开启主库功能先关闭服务sys...

ADB调试技巧记录

一.多个在线设备adb 1. 通过adb devices命令获取所有online设备的serial number。 C:UsersAdministrator>adb devices List of devices attachedemulator-5554   deviceSH0A6PL00243    device 上面表示,当前有两个设备onli...

kvm虚拟机磁盘文件读取小结

kvm虚拟机磁盘挂载还真不是一帆风顺的。xen虚拟化默认就raw格式的磁盘,可以直接挂载,kvm如果采用raw也可以直接挂载,与xen磁盘挂载方式一致。 本文出自:http://koumm.blog.51cto.com 1.kvm虚拟化相比xen虚拟化来说,工具与方法众多,本文列举思路如下: (1)raw格式的磁盘可以直接挂载,可以将qcow2磁盘转换成r...

Supervisor Linux程序进程管理

Supervisor 介绍 在linux或者unix操作系统中,守护进程(Daemon)是一种运行在后台的特殊进程,它独立于控制终端并且周期性的执行某种任务或等待处理某些发生的事件。由于在linux中,每个系统与用户进行交流的界面称为终端,每一个从此终端开始运行的进程都会依附于这个终端,这个终端被称为这些进程的控制终端,当控制终端被关闭的时候,相应的进程都...