国产欧美日韩第一页|日本一二三不卡视频|在线精品小视频,亚洲第一免费播放区,metcn人体亚洲一区,亚洲精品午夜视频

linux下mariadb安裝初始化,字符集設(shè)置

2018-03-07 17:18:09 9701

Linux下安裝Mariadb,我是使用的centos 7.1系統(tǒng),在yum源配置好的情況下

yum search mariadb

搜索結(jié)果如下


==================================================================================== N/S matched: mariadb =====================================================================================
mariadb-bench.x86_64 : MariaDB benchmark scripts and data
mariadb-devel.i686 : Files for development of MariaDB/MySQL applications
mariadb-devel.x86_64 : Files for development of MariaDB/MySQL applications
mariadb-embedded.i686 : MariaDB as an embeddable library
mariadb-embedded.x86_64 : MariaDB as an embeddable library
mariadb-embedded-devel.i686 : Development files for MariaDB as an embeddable library
mariadb-embedded-devel.x86_64 : Development files for MariaDB as an embeddable library
mariadb-libs.x86_64 : The shared libraries required for MariaDB/MySQL clients
mariadb-libs.i686 : The shared libraries required for MariaDB/MySQL clients
mariadb-server.x86_64 : The MariaDB server and related files
mariadb.x86_64 : A community developed branch of MySQL
mariadb-test.x86_64 : The test suite distributed with MariaD
percona-xtrabackup.x86_64 : Online backup for InnoDB/XtraDB in MySQL, Percona Server and MariaDB

  Name and summary matches only, use "search all" for everything.


然后安裝mariadb-server.x86_64   mariadb.x86_64這兩個(gè)包(一個(gè)是服務(wù)一個(gè)是客戶端,不同的系統(tǒng)名字可能不一樣)

yum install mariadb.x86_64

yum install mariadb-server.x86_64

或者 yum groupinstall -y mariadb mariadb-server

或者直接yum install mariadb會(huì)直接裝好(我第一次就是直接使用這個(gè)命令裝好的)

裝完后啟動(dòng)mariadb

systemctl start mariadb

先進(jìn)一下數(shù)據(jù)庫試一下,沒問題就是安裝完成

#########################################################################################

接下來就是初始化了

mysql_secure_installation  #這是一個(gè)快速初始化的命令

 首先他會(huì)提示輸入root密碼

Enter current password for root (enter for none):

初次安裝時(shí)沒有密碼的所以直接回車

然后Change the root password? [Y/n]  修改密碼

Remove anonymous users? [Y/n]   移除匿名用戶,這個(gè)一般都要移除

Disallow root login remotely? [Y/n]  不允許root用戶遠(yuǎn)程登錄,一般是不允許,所以yes

Remove test database and access to it? [Y/n]  刪除test數(shù)據(jù)庫,這個(gè)不是太重要

Reload privilege tables now? [Y/n]  是否重新加載授權(quán)表  yes

這樣基本初始化就完成了

###########################################################################################

設(shè)置字符集一般建議是在配置文件中設(shè)置,也可以在數(shù)據(jù)庫中設(shè)置,在數(shù)據(jù)庫中設(shè)置的話當(dāng)服務(wù)重啟后就會(huì)恢復(fù)默認(rèn)字符集,會(huì)出現(xiàn)亂碼現(xiàn)象

配置文件一般在/etc/my.cnf

vim /etc/my.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

[client]下添加 (有些配置文件沒有[client],是因?yàn)榘?“!includedir /etc/my.cnf.d”這句話,說明其他配置在這個(gè)目錄中)

default-character-set=utf8

然后重啟mariadb

登錄數(shù)據(jù)庫查看字符集是否設(shè)置正確 show variables like "%character%";show variables like "%collation%"

這樣就設(shè)置成功了

創(chuàng)建數(shù)據(jù)庫:

CREATE DATABASE `test2` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci

導(dǎo)入sql文件

Source sql文件路徑


提交成功!非常感謝您的反饋,我們會(huì)繼續(xù)努力做到更好!

這條文檔是否有幫助解決問題?

非常抱歉未能幫助到您。為了給您提供更好的服務(wù),我們很需要您進(jìn)一步的反饋信息:

在文檔使用中是否遇到以下問題: