前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Centos6下使用yum安装MariaDB

Centos6下使用yum安装MariaDB

作者头像
洗尽了浮华
发布2018-03-28 13:25:53
6620
发布2018-03-28 13:25:53
举报
文章被收录于专栏:散尽浮华散尽浮华散尽浮华

1)增加mariaDB的yum源

[root@centos6-test08 ~]# cd /etc/yum.repos.d/
[root@centos6-test08 yum.repos.d]# cp CentOS-Base.repo CentOS-Base.repo.bak
[root@centos6-test08 yum.repos.d]# vim CentOS-Base.repo
......
[mariadb]    
name = MariaDB
baseurl = http://yum.mariadb.org/10.3.5/centos6-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB   
gpgcheck=1

2)yum安装MariaDB

[root@centos6-test08 yum.repos.d]# yum install -y MariaDB-server MariaDB MariaDB-client

安装好后,启动服务
[root@centos6-test08 yum.repos.d]# /etc/init.d/mysql start
[root@centos6-test08 yum.repos.d]# ps -ef|grep mysql
[root@centos6-test08 yum.repos.d]# lsof -i:3306

设置开机启动
[root@centos6-test08 yum.repos.d]# chkconfig mysql on

[root@centos6-test08 yum.repos.d]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 10.3.5-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)]>

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

[root@centos6-test08 yum.repos.d]# 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):      <–初次运行直接回车
  
设置密码
Set root password? [Y/n]                               <– 是否设置root用户密码,输入y并回车或直接回车
New password:                                          <– 设置root用户的密码,比如密码为123456
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]                     <– 是否重新加载权限表,回车

[root@centos6-test08 yum.repos.d]# mysql -p123456
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 19
Server version: 10.3.5-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)

4)接下来配置MariaDB的字符集

[root@centos6-test08 yum.repos.d]# cat /etc/my.cnf
#
# This group is read both both by the client and the server
# use it for options that affect everything
#
[client-server]

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d                              //说明在该配置文件中引入/etc/my.cnf.d 目录下的配置文件

[root@centos6-test08 yum.repos.d]# ls /etc/my.cnf.d/
enable_encryption.preset  mysql-clients.cnf  server.cnf

首先是配置文件/etc/my.cnf.d/server.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

然后配置文件/etc/my.cnf.d/mysql-clients.cnf,在[mysql]中添加
default-character-set=utf8

最后是重启MariaDB,并登陆MariaDB查看字符集
[root@centos6-test08 yum.repos.d]# /etc/init.d/mysql restart
Shutting down MariaDB.. SUCCESS! 
Starting MariaDB.180313 05:47:41 mysqld_safe Logging to '/var/lib/mysql/centos6-test08.err'.
180313 05:47:41 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
 SUCCESS! 

[root@centos6-test08 yum.repos.d]# mysql -p123456
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 10.3.5-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.001 sec)

+----------------------+-----------------+
| Variable_name        | Value           |
+----------------------+-----------------+
| collation_connection | utf8_unicode_ci |
| collation_database   | utf8_unicode_ci |
| collation_server     | utf8_unicode_ci |
+----------------------+-----------------+
3 rows in set (0.001 sec)
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018-03-13 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
云数据库 MariaDB
腾讯云数据库 MariaDB(TencentDB for MariaDB) 让您轻松在云端部署、使用 MariaDB 数据库。MariaDB 是在 MySQL 版权被 Oracle 收购后,由 MySQL 创始人 Monty 创立,其版权授予了“MariaDB基金会(非营利性组织)”以保证 MariaDB 永远开源,良好的开源策略,是企业级应用的最优选择,主流开源社区系统/软件的数据库系统,均已默认配置 MariaDB。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档