1.配置官方的mariadb的yum源,手動建立 mariadb.repo倉庫文件mysql
而後寫入以下內容
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1linux
2.根據操做系統的不一樣版本,centos採用yum安裝指令,ubantu採用apt-get指令安裝:sql
從官網安裝:apt-get install MariaDB-server MariaDB-client -y數據庫
若是中途斷網,或者安裝失敗,能夠先移除配置文件:rm -rf /etc/repos.d/Mariadb.repowindows
而後清空緩存:apt-get clean all centos
3.安裝完成後,啓動mariadb服務端:緩存
systemctl start/stop/restart/stats mariadb服務器
systemctl enable mariadb 開機自啓動ide
.mysql初始化
mysql_secure_installation 這條命令能夠初始化mysql,刪除匿名用戶,設置root密碼等等....編碼
設置mysql的中文編碼支持,修改/etc/my.cnf
4.vi /etc/my.cnf
在[mysqld]中添加參數,使得mariadb服務端支持中文
[mysqld]
character-set-server=utf8
collation-server=utf8_general_ci
2.重啓mariadb服務,讀取my.cnf新配置
systemctl restart mariadb
3.登陸數據庫,查看字符編碼
mysql -uroot -p
輸入 \s 查看編碼
********************************************************************
mysql經常使用命令
desc 查看錶結構
create database 數據庫名
create table 表名
show create database 庫名 查看如何建立db的
show create table 表名; 查看如何建立table結構的
#修改mysql的密碼
set password = PASSWORD('redhat');
#建立mysql的普通用戶,默認權限很是低
create user yining@'%' identified by 'yiningzhenshuai';
#查詢mysql數據庫中的用戶信息
use mysql;
select host,user,password from user;
***********************************************************************************************
給用戶添加權限命令
grant all privileges on *.* to 帳戶@主機名 對全部庫和全部表受權全部權限
grant all privileges on *.* to yining@'%'; 給yining用戶授予全部權限
flush privileges; 刷新受權表
授予遠程登陸的權限命令 (root不能遠程登陸的問題??)
grant all privileges on *.* to yining@'%'; 給yining用戶授予全部權限
grant all privileges on *.* to root@'%' identified by 'redhat'; #給與root權限授予遠程登陸的命令
此時能夠在windows登陸linux的數據庫
mysql -uyining -p -h 服務器的地址 鏈接服務器的mysql