在 CentOS 7(Linux)上安装MariaDB,搭建Mysql服务(Centos 7、mysql)

一、安装MariaDB

安装命令

yum -y install mariadb mariadb-server

安装完成MariaDB,首先启动MariaDB、然后查看服务启动状态

[[email protected] ~]# systemctl start mariadb
[[email protected] ~]# 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.
[[email protected] ~]#

设置开机启动

[[email protected] ~]# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.

接下来进行MariaDB的相关简单配置,首先是设置密码,会提示先输入密码

[[email protected] ~]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we‘ll need the current
password for the root user. If you‘ve just installed MariaDB, and
you haven‘t set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] ^[[A^H^H^H
Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
... Success!

Normally, root should only be allowed to connect from ‘localhost‘. This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n
... skipping.

By default, MariaDB comes with a database named ‘test‘ that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] n
... skipping.

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
... Success!

Cleaning up...

All done! If you‘ve completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
[[email protected] ~]#

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远程登录,回车,

Remove test database and access to it? [Y/n] <– 是否删除test数据库,回车

Reload privilege tables now? [Y/n] <– 是否重新加载权限表,回车

初始化MariaDB完成,接下来测试登录

[[email protected] ~]# 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)]>

完成。

二、配置MariaDB

查看安装

[[email protected] ~]#  rpm -qa | grep mariadb
mariadb-libs-5.5.60-1.el7_5.x86_64
mariadb-5.5.60-1.el7_5.x86_64
mariadb-server-5.5.60-1.el7_5.x86_64

修改配置文件

vi /etc/my.cnf

我这里所有配置都默认安装,开启远程登陆权限,使用root用户操作数据就可以了,对数据编码等设置都可以使用root 权限操作的。

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

时间: 2024-07-30 02:32:45

在 CentOS 7(Linux)上安装MariaDB,搭建Mysql服务(Centos 7、mysql)的相关文章

在Linux CentOS 6.6上安装Python 2.7.9

在Linux CentOS 6.6上安装Python 2.7.9 CentOS 6.6自带的是Python 2.6.6,而编译llvm需要Python 2.7以上. checking for python... /usr/bin/python checking for python >= 2.7... not found configure: error: found python 2.6.6 (/usr/bin/python); required >= 2.7 yum中最新的也是Python

记录CentOS 7.4 上安装MySQL&amp;MariaDB&amp;Redis&amp;Mongodb

记录CentOS 7.4 上安装MySQL&MariaDB&Redis&Mongodb 前段时间我个人Google服务器意外不能用,并且我犯了一件很低级的错误,直接在gcp讲服务器实例给释放掉,导致我的数据全部丢失,现在新搞一个服务器,顺便记录一下CentOS 7.4 MySQL&MariaDB&Redis&Mongodb 的安装 1祝大家:诸事顺利,2019 发大财! 本人将一如既往,更新我的博客,努力为博客园贡献文章! Mysql 安装 随着CentOS

【Linux服务器搭建】——在linux上安装mysql5、tomcat8和jdk8并部署应用

Linux作为java web服务器是首要选择.在工作中也会搭建服务器.今天尝试在linux上搭建tomcat服务器. linux:suse jdk:jre 1.8 tomat:8.0.9 mysql:5.5.39 服务器是用的阿里云服务器.2G内存,双核CPU. 1.mysql安装 下载地址可以使用sohu的镜像进行下载 ,地址:http://mirrors.sohu.com/mysql/ 我下载的名称为: -rw-r--r-- 1 root root 17715414 Jul 21 20:0

linux上安装node.js ,npm,与karma--angularJS环境搭建

安装nodejs   搭建依赖环境 首先安装g++编译器与git,在终端输入如下命令 sudo apt-get install g++ curl libssl-dev apache2-utils sudo apt-get install git-core git如果已经安装则不需要再安装了. 2. 安装node.js 直接输入命令sudo apt-get install nodejs 安装的是0.6版本的,这个会出现问题,导致接下来安装js测试工具karma,出现问题. 所以用下载安装的方式,去

在 RedHat Enterprise、CentOS 或 Fedora Linux 上安装 MongoDB

在 RedHat Enterprise.CentOS 或 Fedora Linux 上安装 MongoDB 1.大纲 ? 备注:采用yum安装后,所有进程将自动在/usr/bin下,如下的mongo.mongod.mongostat以后都可以直接cd /usr/bin之后直接使用. 该教程列出了在 RedHat Enterprise Linux.CentOS Linux.Fedora Linux 及相关系统上部署Mongodb的基本安装流程.该程序使用 .rpm 程序包作为安装基础.10gen

在Linux上用Apache搭建Git服务器

在Linux上用Apache搭建Git服务器 最近在学Linux,终于在Linux上用Apache搭建起了Git服务器,在此记录一下. 服务器:阿里云服务器 Linux版本:CentOS 6.5 Apache版本:Apache/2.2.15 Git版本:git 1.7.1 Git访问方式:基于http的基本验证(非SSL) Apache的安装 1. 安装Apache软件:yum install httpd 2. 设置Apache在服务器启动时运行:chkconfig --levels 235 h

如何在CentOS 5/6上安装EPEL源

原文:http://os.51cto.com/art/201312/420725.htm 如何在CentOS 5/6上安装EPEL源 2013-12-04 14:45 译者:NearTan Linux中国 字号:T | T 我们可以很容易地通过yum命令从EPEL源上获取上万个在CentOS自带源上没有的软件.在文本中,我将展示在CentOS下如何安装EPEL源. AD: EPEL 是什么? EPEL (Extra Packages for Enterprise Linux,企业版Linux的额

在CentOS 6.4上安装Puppet配置管理工具

在CentOS 6.4上安装Puppet配置管理工具 linux, puppetAdd comments 五052013 上篇说了下在ubuntu12.04上安装puppet,安装的版本为puppet2.7.11版本,今天尝试了下在CentOS6.4系统上安装puppet 3.1.1版本,本文参考chenshake的文章 ? 1 2 3 4 OS:centso 6.4 X64 Puppet 3.1.1 Puppet master: master.canghai.com Puppet client

CentOS 5.3上安装Apache+php+Mysql+phpMyAdmin

1.系统下载CentOS 开发社区已发布了新的 5.3 版本.CentOS 5.3 基于 Red Hat Enterpris Linux 5.3.0,其中包括 Kernel 2.6.18.Apache 2.2.PHP 5.1.6.MySQL 5.0.PostgreSQL 8.GNOME 2.16.KDE 3.5.OpenOffice.org 2.3.Firefox 3.0.Evolution 2.12 等等.此外,CentOS 5.3 更新了美工设计,并根据用户的请求恢复了 Contrib 仓库