centos7 Mariadb 安装

1、安装MariaDB
安装命令
[[email protected] ~]# yum -y install mariadb mariadb-server
安装完成MariaDB,首先启动MariaDB
[[email protected] ~]# systemctl start mariadb
设置开机启动
[[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] y 是否设置root用户密码,输入y并回车或直接回车
New password: 设置root用户的密码
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] 是否删除匿名用户,回车
... 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] 是否禁止root远程登录,回车,
... 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.

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

  • 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] 是否重新加载权限表,回车
... 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! (初始化MariaDB完成,接下来测试登录)!
[[email protected] ~]# mysql -uroot -ppassword
ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES) 完成!!
下面我们正式进入 mariadb 的使用中!!
[[email protected] ~]# mysql -u root -p (-u:用户名,默认为root,-p:用户密码)
Enter password: (此处输入设置的密码)
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 11
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)]>
2、配置MariaDB的字符集

文件/etc/my.cnf

[[email protected] ~]# vim /etc/my.cnf
[mysqld]
init_connect=‘SET collation_connection = utf8_unicode_ci‘
init_connect=‘SET NAMES utf8‘
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

Settings user and group are ignored when systemd is used.

If you need to run mysqld under a different user or group,

customize your systemd unit file for mariadb according to the

instructions in http://fedoraproject.org/wiki/Systemd

[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid

#

include all files from the config directory

#
!includedir /etc/my.cnf.d
在[mysqld]标签下添加
“ init_connect=‘SET collation_connection = utf8_unicode_ci‘
init_connect=‘SET NAMES utf8‘
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake ”

文件/etc/my.cnf.d/client.cnf

[[email protected] ~]# vim /etc/my.cnf.d/client.cnf

These two groups are read by the client library

Use it for options that affect all clients, but not the server

[client]

default-character-set=utf8

This group is not read by mysql client library,

If you use the same .cnf file for MySQL and MariaDB,

use it for MariaDB-only client options

[client-mariadb]
在[client]中添加: default-character-set=utf8

文件/etc/my.cnf.d/mysql-clients.cnf

[[email protected] ~]# vim /etc/my.cnf.d/mysql-clients.cnf

These groups are read by MariaDB command-line tools

Use it for options that affect only one utility

[mysql]

default-character-set=utf8
[mysql_upgrade]

[mysqladmin]

[mysqlbinlog]

[mysqlcheck]

[mysqldump]

[mysqlimport]

[mysqlshow]

[mysqlslap]
在[mysql]中添加: default-character-set=utf8

全部配置完成,重启mariadb systemctl restart mariadb

3、之后进入MariaDB查看字符集
[[email protected] ~]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
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 variables like "%character%";show variables like "%collation%";
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)

+----------------------+-----------------+
| Variable_name | Value |
+----------------------+-----------------+
| collation_connection | utf8_unicode_ci |
| collation_database | utf8_unicode_ci |
| collation_server | utf8_unicode_ci |
+----------------------+-----------------+
3 rows in set (0.00 sec)

MariaDB [(none)]>
至此,我们的实验完美结束!

原文地址:http://blog.51cto.com/14128387/2349072

时间: 2024-10-28 09:46:10

centos7 Mariadb 安装的相关文章

数据分析系统DIY1/3:CentOS7+MariaDB安装纪实

打算通过实践,系统学习一下数据分析. 初步计划要完成的三个任务. 一.用VMware装64位CentOS,数据库服务端用CentOS自带的就好. 二.数据采集与预处理用Dev-C++编程解决. 三.用本地Win7 64上的MATLAB R2012b连接数据库进行挖掘分析. 本文就是完成第一个任务的过程. 1.先上centos 官网下载centos7的DVD iso种子,然后把种子上传到百度云离线下载,再拖回本地.4M/s,很快搞定. 2.往VMware里装的时候遇到了问题.安装自检过程中报错"k

centos7 Mariadb安装

yum install mariadb-server mariadb -y 修改配置: [mysqld] default-storage-engine = innodb innodb_file_per_table character-set-server = utf8 collation-server = utf8_general_ci init-connect = 'SET NAMES utf8' ? systemctl start mariadb systemctl enable maria

centos7下安装mariadb

参考: http://www.cnblogs.com/Netsharp/p/5875474.html https://downloads.mariadb.org/mariadb/repositories/#mirror=neusoft&distro=CentOS&distro_release=centos7-amd64--centos7&version=10.1 RDS for MySQL 备份文件恢复到自建数据库 参考: https://help.aliyun.com/knowl

centos7 快速安装 mariadb(mysql)

nbsp; centos7 快速安装 mariadb(mysql) 默认安装 mariadb 5.5.如果安装 mariadb 10.0 需要修改源 Centos 使用YUM安装MariaDB 出于安全考虑,不应该使用 root安装.所以应该新建一个用户 CentOS 7中MARIADB安装配置步骤详解

Centos7 编译安装 Nginx、MariaDB、PHP

前言 本文主要大致介绍CentOS 7下编译安装Nginx.MariaDB.PHP.面向有Linux基础且爱好钻研的朋友.技艺不精,疏漏再所难免,还望指正. 环境简介: 系统: CentOS 7,最小化安装 IP: 192.168.170.128 Nginx: 1.6.1 MariaDB: 5.5.39 PHP: 5.5.16 1.准备工作 1.1.系统硬件准备 尽管Linux能最大化发挥硬件资源,但RHEL/CentOS随着版本增加对最低硬件的配置也越来越高[1].RHEL7/CentOS最低

centos7 yum 安装mariadb

1.安装MariaDB 安装命令 yum -y install mariadb mariadb-server 安装完成MariaDB,首先启动MariaDB systemctl start mariadb 设置开机启动 systemctl enable mariadb 接下来进行MariaDB的相关简单配置 mysql_secure_installation 首先是设置密码,会提示先输入密码 Enter current password for root (enter for none):<–初

Centos7+Mariadb集群-主从配置介绍

近期一直在恶补Linux相关的知识,主要是就是学Linux下的基本日常应用服务器的配置及优化,今天我们主要介绍一下在Centos7下安装及配置Mysql 集群,说到集群,其实就是为了提高服务的高可用性.对于高可用的相关服务今天不是主要介绍内容,今天主要介绍MYSQL的主从配置.对在Linux下的其他服务的介绍及服务高可用负载均衡我们将会在后期的文章中介绍.开始今天的介绍:Centos7+Mysql主从配置. 环境介绍: Hostname:A-S IP:192.168.5.21 Role:Mysq

Centos7下安装及配置Zabbix3.0

说到Zabbix相信很多管理员都使用过,因为zabbix所提供的功能给广大管理员们及时得知自己所管理的服务器的服务状态,当然有很多软件服务(cacti.ngios等)都可以实现zabbix类似的功能,但是对于zabbix的功能相对更强大一点,具体就不细说了,今天我们主要介绍一下,Centos7下安装及配置Zabbix3.0的介绍,具体见下: 在安装服务器的时候我们需要注意一些问题:比如服务器的防火墙.selinux等都会影响到Zabbix的正常通信 环境介绍: OS:Centos7 Servic

CentOS7下安装部署LAMP环境

(1)配置概要:  1. 172.16.100.31主机运行httpd+php服务(php为模块工作模式)  配置两台虚拟主机:wordpress个人博客系统.PHPmyadmin远程控制mysql 2.172.16.100.31主机运行mariadb服务(mysql) (2)配置流程:  首先配置172.16.100.31主机:http服务              1.安装程序:[[email protected]'s linux ~]# yum install httpd php php-