【MySQL】Mariadb安装

Mariadb安装

1.解压

[[email protected] bin]# tar zxvf mariadb-10.3.18-linux-x86_64.tar.gz
[[email protected] bin]# mv mariadb-10.3.18-linux-x86_64 /usr/local/
[[email protected] bin]# cd /usr/local/
[[email protected] local]# mv mariadb-10.3.18-linux-x86_64/ mysql/

2.新建mysql用户

groupadd mysql
useradd -g mysql mysql

chown mysql:mysql -R /usr/local/mysql

3.新建数据库目录

mkdir -p /u01/data
chown mysql:mysql -R /u01/data

4.初始化数据库

scripts/mysql_install_db --user=mysql --datadir=/u01/data

5.查看my.cnf执行的顺序.

[[email protected] support-files]# /usr/local/mysql/bin/mysqld --verbose --help |grep -A 1 'Default options'
2019-09-23 15:25:07 0 [Note] Plugin 'FEEDBACK' is disabled.
2019-09-23 15:25:07 0 [Warning] Could not open mysql.plugin table. Some options may be missing from the help text
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf ~/.my.cnf 

顺序为/etc/my.cnf /etc/mysql/my.cnf ~/.my.cnf

也可以用如下命令查找:

[[email protected] support-files]# locate my.cnf
/etc/my.cnf

6.修改my.cnf

[[email protected] support-files]# vi /etc/my.cnf
[mysqld]
datadir=/u01/data/
socket=/tmp/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
log-error=/u01/data/mysqld.log
pid-file=/tmp/mysqld.pid

7.生成自启动脚本

[[email protected] mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[[email protected] mysql]# vi /etc/init.d/mysqld
###修改data目录
datadir=/u01/data
[[email protected] mysql]# chkconfig --add mysqld
[[email protected] mysql]# chkconfig mysqld on

错误

[[email protected] mysql]# service mysqld start
Starting MariaDB.190923 15:36:00 mysqld_safe Logging to '/u01/data/mysqld.log'.
190923 15:36:00 mysqld_safe Starting mysqld daemon with databases from /u01/data/
 SUCCESS!
[[email protected] mysql]# tail -f /u01/data/mysql.log
tail: cannot open `/u01/data/mysql.log' for reading: No such file or directory
tail: no files remaining

[[email protected] data]# ls -l mysqld.log
-rw-rw----. 1 mysql mysql 1880 Sep 23 15:36 mysqld.log
[[email protected] data]# chmod 777 mysqld.log
[[email protected] data]# service mysqld restart

[[email protected] data]# tail -f /u01/data/mysqld.log
2019-09-23 15:37:28 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2019-09-23 15:37:28 0 [Note] InnoDB: 10.3.18 started; log sequence number 1630824; transaction id 21
2019-09-23 15:37:28 0 [Note] InnoDB: Loading buffer pool(s) from /u01/data/ib_buffer_pool
2019-09-23 15:37:28 0 [Note] Plugin 'FEEDBACK' is disabled.
2019-09-23 15:37:28 0 [Note] InnoDB: Buffer pool(s) load completed at 190923 15:37:28
2019-09-23 15:37:28 0 [Note] Server socket created on IP: '::'.
2019-09-23 15:37:28 0 [Note] Reading of all Master_info entries succeeded
2019-09-23 15:37:28 0 [Note] Added new Master_info '' to hash table
2019-09-23 15:37:28 0 [Note] /usr/local/mysql/bin/mysqld: ready for connections.
Version: '10.3.18-MariaDB'  socket: '/tmp/mysql.sock'  port: 3306  MariaDB Server

8.修改环境变量

[[email protected] data]# vi /etc/profile
export PATH=/usr/local/mysql/bin:$PATH
[[email protected] data]# source /etc/profile

9.mysql 安全配置

[[email protected] data]# 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.

##是否设置root用户密码
Set root password? [Y/n] Y
##新的root密码
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.

## 是否禁止root远程登录
Disallow root login remotely? [Y/n] Y
 ... Success!

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.

## 是否删除test数据库
Remove test database and access to it? [Y/n] Y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

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!

10.进入mysql

[[email protected] data]# mysql -uroot -predhat
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 19
Server version: 10.3.18-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 |
+--------------------+
3 rows in set (0.001 sec)

原文地址:https://www.cnblogs.com/zhangshengdong/p/11724984.html

时间: 2024-11-20 03:16:24

【MySQL】Mariadb安装的相关文章

Mysql MariaDB安装

1.安装 本人使用的是CentOS 7 ,默认yum安装,但默认yum安装版本有点低,可根据需要选择升级,我这里选择先升级再安装. 更新yum //更新yum包 yum -y update 配置yum源 vi /etc/yum.repos.d/MariaDB.repo 打开的文本中输入以下内容: [mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.1/rhel7-amd64 gpgkey=https://yum.mariadb

centos上安装mysql/mariadb安装gogs

最小安装: 1. 选择English 2. DATE & TIME 修改好本地时间 SOFTWARE SELECTION默认的Minimal Install就好 INSTALLATION DESTINATION选一下 然后,Begin Installation 3. ROOT PASSWORD设置ROOT密码 USER CREATION设置新用户,勾选Make this user administrator 等待安装完成,点Reboot按钮. 配置静态IPv4: $ systemctl stat

Opensuse下安装MySQL / MariaDB

MySQL是流行的跨平台的数据库管理系统,经常和Php.Apache/nginx组成网页服务平台.MySQL公司先被Sun收购,Sun又被Oracle收购,给开源社区带来的打击不小.因为Oracle自己是做数据库起家,不可能对这个开源竞争对手有好处,MySQL闭源的声音越来越多.MySQL作者Michael Widenius自己创办了新公司Monty Program AB,在MySQL基础上新创了MariaDB开源数据库.MariaDB带来更好的数据库管理特性,更好的自由开源保障.所以openS

LAMP架构(LAMP介绍,mysql/mariaDB介绍,Mysql安装)

一.LAMP架构介绍: Linux+  Apache(httpd)+ mysql  +   php 操作系统+外网服务软件 + 存储软件 + 脚本语言(由C开发) PHP网站 三个角色可以装在一台机器,也可以分开,但是httpd要和php在一起(php是以模块的形式和apache结合在一起的,apache通过php和mysql打交道,) 动态请求:用户通过账号和密码登录apache,apache通过php去mysql里比对数据,对上后apache会返回给用户登录状态 静态请求:用户通过apach

LAMP+LNMP(二) MySQL/Mariadb概述与安装实践

一.MySQL/Mariadb概述MySQL是由my sql公司于1995年开发的关系型数据库管理软件,mysql开发后多次经过版本更替,最新的是5.7GA/8.0DMR,my sql公司自身也经历了两次收购,首先是被sun公司收购,然后被Oracle收购,所以目前MySQL属于Oracle旗下的商用软件. 2009年,MySQL的一位原作者与部分MySQL的开发者开发了Mariadb.其中Mariadb5.5对应了MySQL5.5,10.0对应了5.6. Mariadb本身被Google. M

liunx安装mysql(mariadb)

liunx安装mysql(mariadb) 1.配置mariadb的yum源,新建一个Mariadb.repo仓库文件#编辑创建mariadb.repo仓库文件 vi /etc/yum.repos.d/MariaDB.repo 2.修改mariadb.repo仓库文件,写入以下内容 vi /etc/yum.repos.d/MariaDB.repo [mariadb](10几k没法下) name = MariaDB baseurl = http://yum.mariadb.org/10.1/cen

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

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

Centos7安装Mysql(Mariadb)

一:安装方式 yum安装(配置yum源) 1- centos官方的yum源 #不同的yum源,软件包的名字也可能不一样,区分大小写 !!!! 2- 阿里云的yum源(下载速度快,但是版本较低) 安装命令如下: (由于网速问题,我选择用阿里云的精简版) yum install mariadb-server mariadb 3- mysql官方的yum源 (版本你自由去选择,下载较慢,文件完整性最好) 配置如下方式 1.找到yum仓库目录,创建repo文件 touch /etc/yum.repos.

MySQL/MariaDB数据库基于SSL实现主从复制

前言 备份数据库是生产环境中的首要任务,有时候不得不通过网络进行数据库的复制,由于MySQL/MariaDB的主从复制是明文传送的,如果在生产环境中跨网络传送,数据的安全性就无法完全保证,为了解决这一问题,我们需要一种安全的方式进行传送,即基于SSL加密进行数据传输. 部署配置 实验拓扑 实验环境 系统环境:CentOS6.6 数据库版本:mariadb-5.5.36 #注意:主从服务器数据库版本须一致:主从服务器时间须同步 #此实验从服务器只做一组为例 配置主从复制 安装mariadb [[e