centos7.3安装mariadb数据库

centos7.3安装mariadb


1.开始安装, 创建MariaDB.repo文件

vim /etc/yum.repos.d/MariaDB.repo
[mariadb]
name = MariaDB
baseurl = https://mirrors.ustc.edu.cn/mariadb/yum/10.1/centos7-amd64/
gpgkey=https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1

2.运行安装命令安装MariaDB

 yum -y install MariaDB-server MariaDB-client

3.下载安装包,进行自动安装,安装成功之后启动MariaDB服务,并设为开机自启。

1,systemctl start mariadb #启动服务
2,systemctl enable mariadb #设置开机启动
3,systemctl restart mariadb #重新启动
4,systemctl stop mariadb.service #停止MariaDB
  1. 登录到数据库

    mysql -uroot -p

5.进行MariaDB的相关简单配置,使用

   mysql_secure_installation
   命令进行配置(先退出数据库)。

首先是设置密码,会提示先输入密码

	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] <– 是否重新加载权限表,回车

6.配置MariaDB的字符集
使用vim /etc/my.cnf.d/server.cnf命令编辑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 

7.配置初始化完成,重启Mariadb。

   systemctl restart mariadb
   
   之后进入Mariadb,查看字符集。
   
   show variables like "%character%";show variables like "%collation%";

8.添加用户,设置权限(用户名和密码 为 root 可自行修改)

    create user root@localhost identified by 'root';
  1. 授予外网登陆权限

    grant all privileges on *.* to username@'%' identified by 'password';
    

10.启动mariadb数据库

      systemctl start mariadb  //启动数据库
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值