詳解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.pswp.cn/news/383098.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/383098.shtml
英文地址,請注明出處:http://en.pswp.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;弄懂了字體反爬是個啥玩意。…