详解Linux下通过yum安装Mariadb/MySQL数据库(腾讯云也适用)

1. 安装Mariadb

  1. 安装命令
yum -y install mariadb mariadb-server
  1. 安装完成MariaDB,首先启动MariaDB
systemctl start mariadb
  1. 设置开机启动
systemctl enable mariadb

MariaDB的相关简单配置

  1. 此命令进入到配置相关界面
mysql_secure_installation
  1. 首先是设置密码,会提示先输入密码

Enter current password for root (enter for none):<–初次运行直接回车

  1. 设置密码

Set root password? [Y/n] <– 是否设置root用户密码,输入y并回车或直接回车
New password: <– 设置root用户的密码
Re-enter new password: <– 再输入一次你设置的密码

  1. 其他配置

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

mariadb字符集配置(重点)

文件/etc/my.cnf配置

  1. 命令
vi /etc/my.cnf

此处直接给出完整的文件,自己对照[mysqld]标签下的不同

# Example MariaDB config file for very large systems.
#
# This is for a large system with memory of 1G-2G where the system runs mainly
# MariaDB.
#
# MariaDB programs look for option files in a set of
# locations which depend on the deployment platform.
# You can copy this option file to one of those
# locations. For information about these locations, do:
# 'my_print_defaults --help' and see what is printed under
# Default options are read from the following files in the given order:
# More information at: http://dev.mysql.com/doc/mysql/en/option-files.html
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.# The following options will be passed to all MySQL clients
[client]
#password       = your_password
port            = 3306
socket          = /var/lib/mysql/mysql.sock# Here follows entries for some specific programs# The MySQL server
[mysqld]
port            = 3306
socket          = /var/lib/mysql/mysql.sock
skip-external-locking
key_buffer_size = 384M
max_allowed_packet = 1M
table_open_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size = 32M
lower_case_table_names = 1
sql_mode=
default-storage-engine = innodb
innodb_file_per_table
max_connections = 4096
collation-server = utf8_general_ci
character-set-server = utf8# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 8# Point the following paths to a dedicated disk
#tmpdir         = /tmp/# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (via the "enable-named-pipe" option) will render mysqld useless!
#
#skip-networking# Replication Master Server (default)
# binary logging is required for replication
log-bin=mysql-bin# required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id       = 1# Replication Slave (comment out master section to use this)
#
# To configure this host as a replication slave, you can choose between
# two methods :
#
# 1) Use the CHANGE MASTER TO command (fully described in our manual) -
#    the syntax is:
#
#    CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>,
#    MASTER_USER=<user>, MASTER_PASSWORD=<password> ;
#
#    where you replace <host>, <user>, <password> by quoted strings and
#    <port> by the master's port number (3306 by default).
#
#    Example:
#
#    CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,
#    MASTER_USER='joe', MASTER_PASSWORD='secret';
#
# OR
#
# 2) Set the variables below. However, in case you choose this method, then
#    start replication for the first time (even unsuccessfully, for example
#    if you mistyped the password in master-password and the slave fails to
#    connect), the slave will create a master.info file, and any later
#    change in this file to the variables' values below will be ignored and
#    overridden by the content of the master.info file, unless you shutdown
#    the slave server, delete master.info and restart the slaver server.
#    For that reason, you may want to leave the lines below untouched
#    (commented) and instead use CHANGE MASTER TO (see above)
#
# required unique id between 2 and 2^32 - 1
# (and different from the master)
# defaults to 2 if master-host is set
# but will not function as a slave if omitted
#server-id       = 2
#
# The replication master for this slave - required
#master-host     =   <hostname>
#
# The username the slave will use for authentication when connecting
# to the master - required
#master-user     =   <username>
#
# The password the slave will authenticate with when connecting to
# the master - required
#master-password =   <password>
#
# The port the master is listening on.
# optional - defaults to 3306
#master-port     =  <port>
#
# binary logging - not required for slaves, but recommended
#log-bin=mysql-bin
#
# binary logging format - mixed recommended
#binlog_format=mixed# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = /var/lib/mysql
#innodb_data_file_path = ibdata1:2000M;ibdata2:10M:autoextend
#innodb_log_group_home_dir = /var/lib/mysql
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 384M
#innodb_additional_mem_pool_size = 20M
# Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 100M
#innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50[mysqldump]
quick
max_allowed_packet = 16M[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates[myisamchk]
key_buffer_size = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M[mysqlhotcopy]
interactive-timeout

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

vi /etc/my.cnf.d/client.cnf

在[client]中添加

default-character-set=utf8

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

vi /etc/my.cnf.d/mysql-clients.cnf

在[mysql]中添加

default-character-set=utf8

全部配置完成,重启mariadb

systemctl restart mariadb

如果重启不成功,在日志文件里查看错误信息

cd var/log/mariadb

这个目录下有mariadb日志文件,腾讯云和本地的文件名称不一样,但都在这个目录下,自己去看

MariaDB查看字符集

show variables like "%character%"

配置好的结果如下
在这里插入图片描述

3、添加用户,设置权限

创建用户命令

mysql>create user username@localhost identified by 'password';
直接创建用户并授权的命令
mysql>grant all on . to username@localhost indentified by 'password';

授予外网登陆权限

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

授予权限并且可以授权

mysql>grant all privileges on . to username@'hostname' identified by 'password' with grant option;

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/383098.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【剑指offer】_13 圆圈中最后的数

题目描述 年六一儿童节,牛客都会准备一些小礼物去看望孤儿院的小朋友,今年亦是如此。HF作为牛客的资深元老,自然也准备了一些小游戏。其中,有个游戏是这样的:首先,让小朋友们围成一个大圈。然后,他随机指定一个数m,让编号为0的小朋友开始报数。每次喊到m-1的那个小朋友要出列唱…

【剑指offer】_14 不用加减乘除做加法

题目描述 写一个函数&#xff0c;求两个整数之和&#xff0c;要求在函数体内不得使用、-、*、/四则运算符号。 解题思路 首先看十进制是如何做的&#xff1a; 5712&#xff0c;三步走 第一步&#xff1a;相加各位的值&#xff0c;不算进位&#xff0c;得到2。 第二步&#x…

海量数据处理(位图和布隆过滤器)

哈希切割 给一个超过100G大小的log file, log中存着IP地址, 设计算法找到出现次数最多的IP地址&#xff1f; 与上题条件相同&#xff0c;如何找到top K的IP&#xff1f;如何直接用Linux系统命令实现 解决思路 找到出现次数最多的IP地址 要找到前TopK的IP地址&#xff0c;就…

C++11新特性的总结

C11新特性 auto关键字(C11&#xff09;基于范围的for循环(C11&#xff09;. 指针空值nullptr(C11&#xff09;C动态内存管理序列式容器 array forward_list;继承和多态:final overridedelete:不生成默认的成员函数default:强制编译器生成默认的成员函数智能指针:unique_ptr,sh…

详解C++中右值引用

98中的引用 概念特性引用的使用场景三种传参方式效率的比较探索:引用的底层实现方式----->指针 T&------>T* constconst T&---->const T*const 引用和指针的区别 引用的总结 11中的右值引用 为什么要有右值引用 为了提高程序运行效率&#xff0c;C11中引…

C++中的lambda表达式和线程库

98中的一个例子 如果想要对一个数据集合中的元素进行排序&#xff0c;可以使用std::sort方法 #include <algorithm> #include <functional> int main() {int array[] {4,1,8,5,3,7,0,9,2,6};// 默认按照小于比较&#xff0c;排出来结果是升序std::sort(array, a…

文件压缩(Huaffman树的概念及其实现)

什么是压缩 想办法让源文件变得更小并能还原。 为什么要进行文件压缩 文件太大&#xff0c;节省空间提高数据再网络上传输的效率对数据有保护作用—加密 文件压缩的分类 无损压缩 源文件被压缩后&#xff0c;通过解压缩能够还原成和源文件完全相同的格式 有损压缩 解压缩之…

详解STL中的空间配置器(SGI版本)

空间配置器 1.什么是空间配置器 为各个容器高效的管理空间(空间的申请与回收)的 2.为什么需要空间配置器 各种容器----->可以存放元素---->底层需要空间 new 申请空间 operator new ---->malloc调用构造函数------完成对象的构造 动态内存管理总结 前面的容器…

【剑指offer】_15数组中重复的数字

题目描述 在一个长度为n的数组里的所有数字都在0到n-1的范围内。 数组中某些数字是重复的&#xff0c;但不知道有几个数字是重复的。也不知道每个数字重复几次。请找出数组中任意一个重复的数字。 例如&#xff0c;如果输入长度为7的数组{2,3,1,0,2,5,3}&#xff0c;那么对应的…

【剑指offer】_16 构建乘积数组

题目描述 给定一个数组A[0,1,…,n-1],请构建一个数组B[0,1,…,n-1],其中B中的元素B[i]A[0]*A[1]*...*A[i-1]*A[i1]*...*A[n-1]。不能使用除法。 解题思路 设有数组大小为5。 对于第一个for循环 第一步&#xff1a;b[0] 1; 第二步&#xff1a;b[1] b[0] * a[0] a[0] 第三…

【剑指offer】_17正则表达式的匹配

题目描述 请实现一个函数用来匹配包括’.‘和*的正则表达式。模式中的字符’.表示任意一个字符&#xff0c;而*表示它前面的字符可以出现任意次&#xff08;包含0次&#xff09;。 在本题中&#xff0c;匹配是指字符串的所有字符匹配整个模式。例如&#xff0c;字符串"aaa…

大四阶段的社会实践的主要目的是_疫情当前,大三大四的学生“很惨”?大一大二的学生也别松懈...

大四毕业生不容易这次疫情对于高校学生而言&#xff0c;可以说是各有各的难处&#xff0c;“这届毕业生很惨”更是屡上热搜。不可否认&#xff0c;大四毕业生确实很不容易&#xff0c;论文答辩、毕业、求职就业等都受到了影响&#xff0c;虽然有困难&#xff0c;但各方都在积极…

【剑指offer】_18 数据流中的中位数

题目描述 如何得到一个数据流中的中位数&#xff1f;如果从数据流中读出奇数个数值&#xff0c;那么中位数就是所有数值排序之后位于中间的数值。如果从数据流中读出偶数个数值&#xff0c;那么中位数就是所有数值排序之后中间两个数的平均值。我们使用Insert()方法读取数据流…

【剑指offer】_19 滑动窗口中的最大值

题目描述 给定一个数组和滑动窗口的大小&#xff0c;找出所有滑动窗口里数值的最大值。例如&#xff0c;如果输入数组{2,3,4,2,6,2,5,1}及滑动窗口的大小3&#xff0c;那么一共存在6个滑动窗口&#xff0c;他们的最大值分别为{4,4,6,6,6,5}&#xff1b; 针对数组{2,3,4,2,6,2,…

android 文字反转_多文字共享信息系统

欧阳贵林 www.HeZi.net首发表于2016年03月23日“ 处在信息时代的开端&#xff0c;信息技术不应有特殊的文字性&#xff0c;需要创建多文字共享信息系统&#xff0c;给各国文字一个公平的参与信息与科技创新发展的平台。这是世界的事&#xff0c;更是中国事。”01人类语言语言文…

LeetCode【1--两数之和】 LeetCode【2--两数相加】

两数之和 题目描述 给定一个整数数组 nums 和一个目标值 target&#xff0c;请你在该数组中找出和为目标值的那 两个 整数&#xff0c;并返回他们的数组下标。 你可以假设每种输入只会对应一个答案。但是&#xff0c;你不能重复利用这个数组中同样的元素。 解题思路 直接两…

input数字开头不能为0_李商隐为初恋写诗,每句以数字开头,最后10字一直被仿从未被超越...

上学时&#xff0c;每次写作文&#xff0c;老师总爱在耳边念叨&#xff1a;“你的作文得让阅卷老师看得懂&#xff0c;不然不可能给你高分的&#xff01;”每次听到话&#xff0c;笔者总是用李商隐的诗来和他斗嘴。是的&#xff0c;李商隐的诗作常常是让人读不懂的&#xff0c;…

lsass.exe 当试图更新密码时_“驱动人生”下载器木马再度更新-你应该注意什么?...

360安全大脑监测到通过"驱动人生"供应链攻击传播的挖矿木马在1月30日下午4时左右再次更新。此次更新中&#xff0c;木马在此前抓取系统帐户密码的基础上增加了抓取密码hash值的功能&#xff0c;并试图通过pass the hash攻击进行横向渗透&#xff0c;使得该木马的传播…

LeetCode【3--无重复的最长字串】 LeetCode【4--有序数组中的中位数】

无重复的最长字串 题目描述 给定一个字符串&#xff0c;请你找出其中不含有重复字符的 最长子串 的长度。 解题思路 看到这道题&#xff0c;其实就两个步骤&#xff0c;遍历字符串&#xff0c;记录当前字符有没有重复。 重复一般解决就是哈希&#xff0c;这里用个数组表示…

hwt字体转换ttf_五分钟教你弄懂了字体反爬是个啥

今天的文章内容主要是关于字体反爬。目前已知的几个字体反爬的网站是猫眼&#xff0c;汽车之家&#xff0c;天眼查&#xff0c;起点中文网等等。以前也看过这方面的文章&#xff0c;今天跟个老哥在交流的时候&#xff0c;终于实操了一把&#xff0c;弄懂了字体反爬是个啥玩意。…