CentOS7系统安装 Maria DbMYSQL教程

一、背景
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进行官方支持,并且与其他存储库软件不兼容的可能性很小。

二、开始之前

$ 表示系统的一般权限,不用使用root 超级管理员权限配置。


要检查您的主机名:

$ hostname -f
$ hostname

 

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

更新您的系统:

$ sudo yum update

 

安装并启动MariaDB

$ sudo yum install mariadb-server

  


启用MariaDB以在启动时启动,然后启动该服务:

 

$ sudo systemctl enable mariadb
$ sudo systemctl start mariadb

默认情况下,MariaDB将绑定到localhost(127.0.0.1)。

注意

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

 


  

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

 

 

 查询数据库列表

 

$ show databses;

 

 

 

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


 

 

保护MariaDB服务器

  1. 运行mysql_secure_installation脚本以解决默认MariaDB安装中的几个安全问题:
   sudo mysql_secure_installation

您可以选择更改MariaDB root密码,删除匿名用户帐户,禁用localhost之外的root登录,以及删除测试数据库。建议您对这些选项回答yes

使用MariaDB

与MariaDB交互的标准工具是mariadb客户端,它随mariadb-server包一起安装。MariaDB客户端通过终端使用。

Root登录

  1. 以root用户身份登录MariaDB:
   mysql -u root -p
  1. 出现提示时,输入当mysql_secure_installation脚本运行时分配的root密码。

然后,您将看到欢迎标题和MariaDB提示,如下所示:

   MariaDB [(none)]>
  1. 要为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   (\r) 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   (\n) Disable pager, print to stdout.
   notee     (\t) 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)]>

创建一个新的MariaDB用户和数据库

  1. 在下面的示例中,testdb是数据库的名称,testuser是用户,password是用户的密码:
   create database testdb;
   create user 'testuser'@localhost identified by 'password';
   grant all on testdb.* to 'testuser' identified by 'password';

您可以通过在分配数据库权限时创建用户来缩短此过程:

   create database testdb;
   grant all on testdb.* to 'testuser' identified by 'password';
  1. 然后退出MariaDB:
   exit

创建示例表

  1. 重新登录testuser
   mysql -u testuser -p
  1. 创建一个名为customers的示例表。这将创建一个表,其中包含INT整数类型的客户ID字段(对于新记录自动递增,用作主键),以及用于存储客户名称的两个字段:
   use testdb;
   create table customers (customer_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, first_name TEXT, last_name TEXT);
  1. 查看新表:
   show tables;
  1. 然后退出MariaDB:
   exit

重置MariaDB Root密码

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

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

优化MariaDB

MySQL Tuning Primer可用于优化MariaDB服务器。理想情况下,MariaDB实例应该在运行Tuner之前至少运行24小时。实例运行的时间越长,MySQL Tuner给出的建议就越好。

  1. 该脚本需要安装bc语言:
   sudo yum install bc
  1. 将MySQL Tuner下载到您的主目录并使其可执行:
   wget http://www.day32.com/MySQL/tuning-primer.sh
   chmod u+x tuning-primer.sh
  1. 运行它:
   sudo ./tuning-primer.sh

系统将询问您是否要针对与/var/lib/mysql/mysql.sock不同的MySQL socket 运行脚本。选择N。然后会询问您是否有登录信息。输入y,然后询问时输入凭据。

MySQL Tuning Primer是优化MariaDB服务器的一个很好的起点。

 

 

 

 

 

原文地址:https://www.cnblogs.com/sopcce/p/10593564.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


安装开始...1.打开“https://dev.mysql.com/downloadsepo/yum/”下载Mysql源      将下载好的mysql源上传linux服务器 2.yumlocalinstallmysql80*#安装源 centos7中默认安装的是mariadb数据库,如果想要安装mysql,首先要移除mariadb;
安装Helm3#官网下载慢#wgethttps://get.helm.sh/helm-v3.5.4-linux-amd64.tar.gzwgethttp://qiniu.dev-share.top/helm-v3.5.4-linux-amd64.tar.gztar-zxvfhelm-v3.5.4-linux-amd64.tar.gzcplinux-amd64/helm/usr/local/bin#查看helmclient版本helmversion
通过Linux命令行启动用的指令:systemctlstartmariadb.service反馈:Failedtostartmariadb.service:Unitmariadb.servicenotfound.MariaDB简介MariaDB是MySQL的一个分支,MariaDB打算保持与MySQL的高度兼容性,确保具有库二进制奇偶校验的直接替换功能,以及与MySQLAPI和命令
InstallingMariaDBServer10.4TodeployMariaDBCommunityServer10.4onRHEL7orCentOS7,firstdownloadandusethe mariadb_repo_setup scripttoconfiguretheMariaDBrepositoriesforYUM:$sudoyuminstallwget$wgethttps://downloads.mariadb.com/
阅读目录一什么是存储引擎二mysql支持的存储引擎三使用存储引擎一什么是存储引擎mysql中建立的库--> 文件夹库中建立的表--> 文件现实生活中我们用来存储数据的文件有不同的类型,每种文件类型对应各自不同的处理机制:比如处理文本用txt类型,处理表格用excel,处理图片
1、安装MariaDB安装命令yum-yinstallmariadbmariadb-server安装完成MariaDB,首先启动MariaDBsystemctlstartmariadb设置开机启动systemctlenablemariadb[root@node1~]#systemctlenablemariadbCreatedsymlinkfrom/etc/systemd/system/multi-user.target.wants/m
Centos7.5 刚安装的mariadb数据库报错报错:ERROR1045(28000):Accessdeniedforuser'root'@'localhost'(usingpassword:NO)原因一:没有启动数据库解决方法:systemctlstartmariadbsystemctlenablemariadb原因二:未知解决方法:[root@db01~]#
基于YUM安装的mariadb多实例.=================================================================1.yum安装mariadb-server包#yuminstallmariadb-server2.创建多实例对应的目录结构#mkdir/mysql/{3306,3307,3308}/{data,etc,socket,log,bin,pid}-pv#tree/mysql//mysql/
一、系统环境[root@localhost~]#cat/etcedhat-releaseCentOSLinuxrelease7.6.1810(Core)二、mysql安装#yuminstallmysqlmysql-servermysql-devel安装mysql-server失败,如下图:[root@localhost~]#yuminstallmysql-serverLoadedplugins:fastestmirrorLoadingm
数据库的选择两大点是:开源和跨平台,满足这三点MySQL、MongoDB和MariaDB。其中MariaDB是MySQL的分支,也是它的进阶产品,未来很有可能替代MySQL。与MySQL相比较,MariaDB更强的地方在于:Maria 存储引擎PBXT存储引擎XtraDB 存储引擎FederatedX 存储引擎更快的复制查询处理线
使用Navicat连接数据库时出现了 HostxxxisnotallowedtoconnecttothisMariaDbserver的情况。发现了是因为授权的问题,使得连接权限受阻。所以,只需要进入数据库中,给予其权限即可。具体解决代码如下:[root@localhost~]#mysql-uroot-pEnterpassword:#首先进入mys
1.临时表当绘画结束时,临时表会自动销毁,无法用showtables查看临时表。MariaDB[jason]>createtemporarytabletmp(prochar(30),citychar(30));QueryOK,0rowsaffected(0.01sec)MariaDB[jason]>insertintotmpvalues('shanghai','shanghai');QueryOK,1
为了看阳光我来到世上数据库介绍数据库是一个存放数据的仓库,目前市面上最流行的数据库大致氛围的两种,一种叫做关系型数据库,一种叫做非关系型数据库,而关系型数据库近期流行的即为mysql,mysql原本是一个开源的数据库后被oracle公司收购,开始进行服务收费,因此,市面上大多数免费
1,Linux上的mysql MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可。开发这个分支的原因之一是:甲骨文公司收购了MySQL后,有将MySQL闭源的潜在风险,因此社区采用分支的方式来避开这个风险。MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能轻松
启动Mariadb前提需安装mariadb-server-安装mariadb-serveryuminstall-ymariadb-server-启动服务systemctlstartmariadb.service-添加到开机启动systemctlenablemariadb.service-安全设置,以及修改数据库管理员密码mysql_secure_installation-启
1、查看是否安装及可用安装:yumlist|grepmaria2、安装maria(依赖其他几个安装包):yuminstallmariadb-server.x86_64输入'y'继续安装直到安装结束3、检查是否安装:4、安装完后登录提示错误:mysql-uroot-p是由于安装完但是并未启动maria服务5、启动maria有以下几种方法:system
通过yum安装mariadb,并配置MySQL主从服务器主服务器:192.168.10.11从服务器:192.168.10.12#!/bin/bash#====================================================#Author:Mr.Song#CreateDate:2019-02-21#Description:autoconfigMySQLmaster&slave#=====================
实验:实现基于SSL加密的主从复制实验步骤:环境:三台主机,一台CA:200,一台master:150,一台slave:100平时都是在CA上帮用户生成私钥,在服务器上做的1CA,master,slave的证书相关文件mkdir/etc/my.cnf.d/sslcd/etc/my.cnf.d/sslopensslgenrsa2048>cakey.pemopensslreq-new-x509-k
MariaDB[db1]>select*fromstudent;+----+------+-----+--------+-------+|id|name|age|gender|phone|+----+------+-----+--------+-------+|1|a|20|m|119||2|b|20|m|120||3|c|20|m|110
过年了,在老家闲余时间想敲敲代码,发现在安装mariaDb的时候一直报错错误信息:Service‘MySQL’(MySQL)Faildtostart,Verifythatyouhavesuffcientprivilegestostartsystemservices.服务的MySQL(MySQL)启动错误,确认你有权限启动系统服务。记得多年前在使用sqlserver数