1:添加 MariaDB yum 仓库

vi /etc/yum.repos.d/MariaDB.repo
在该文件中添加以下内容保存:

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.2/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=

2:安装 MariaDB

yum install MariaDB-server MariaDB-client -y

(1)安装完毕后,立即启动数据库服务守护进程。

systemctl start mariadb

(2)设置 MariaDB 在操作系统重启后自动启动服务

systemctl enable mariadb

(3)查看 MariaDB 服务当前状态

systemctl status mariadb

3:对 MariaDB 进行安全配置

设置 MariaDB 的 root 账户密码,删除匿名用户,禁用 root 远程登录,删除测试数据库,重新加载权限表。

mysql_secure_installation

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] 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. 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!

4:基本配置

(1)设置数据库字母大小写不敏感

vi /etc/my.cnf.d/server.cnf

在[mysqld]下加上】
lower_case_table_names=

(2)设置MariaDB数据库默认编码

vi /etc/my.cnf.d/client.cnf
在[client]字段里加入
default-character-set=utf8 vi /etc/my.cnf.d/server.cnf
在[mysqld]字段里加入
character-set-server=utf8

(3)修改默认端口号3306修改为3366

vi /etc/my.cnf.d/client.cnf
在[client]字段修改
port= vi /etc/my.cnf.d/server.cnf
在[mysqld]字段里加入
port=

(4)修改最大连接数

vi /etc/my.cnf.d/server.cnf
[mysqld] 下面增加下面配置:
max_connections= 查看最大连接数
show variables like '%max_connections%';

(5)修改max_allowed_packet

vi /etc/my.cnf.d/server.cnf
[mysqld] 下面增加下面配置:
max_allowed_packet=16M

5:最后重启 MariaDB 配置生效

systemctl restart mariadb

最新文章

  1. C++基础知识
  2. JavaScript 数组 length 属性获取数组长度或设置数组元素的数目
  3. 奔跑的歌颂 diskgenius 找回了20G数据
  4. 吉他笔记 solo 和弦 推弦 音程
  5. Redis学习笔记九:独立功能之慢查询日志
  6. HDU 4864 Task (贪心+STL多集(二分)+邻接表存储)(杭电多校训练赛第一场1004)
  7. 从零开始PHP攻略(2)——操作符与迭代整理
  8. hdu 4882 ZCC Loves Codefires (贪心 推导)
  9. 从Delphi 7升级到Delphi XE
  10. 关于响应式、媒体查询和media的关系 、流媒体布局flex 和em rem像素的使用 我有一些废话要讲.....
  11. bzoj1336: [Balkan2002]Alien最小圆覆盖
  12. .NET 对 XML 进行创建,增加,删除,修改操作整理
  13. Git运用基础之如何删除Github上不想要的项目
  14. C语言--测试电脑存储模式(大端存储OR小端存储)
  15. 最简单的基于FFmpeg的内存读写的例子:内存播放器
  16. laravel5.4 向闭合函数内部传递参数
  17. linux 依赖解决办法
  18. 解决p4c安装时protobuf未定义引用的错误
  19. 创建WRAPPER时, SQL20076N 未对指定的操作启用数据库的实例。
  20. 经典SQL面试题(转)

热门文章

  1. 测试mybatis延迟加载错误与解决方法
  2. DOM是浏览器提供给开发者的语柄、套接字、文件接口
  3. iOS 应用逆向工程分析流程图
  4. Docker Quick Start
  5. day004-python运算符与基本数据类型
  6. [Javascript] Working with Static Properties on a Class
  7. linux 打印当前工作目录
  8. 清华大学&中国人工智能学会:2019人工智能发展报告
  9. 洛谷p3398仓鼠找suger题解
  10. 【概率DP】$P2059$ 卡牌游戏