Centos 安裝mariadb
yum install mariadb mariadb-server
systemctl start mariadb ==> 啟動mariadb
systemctl enable mariadb ==> 開機自啟動
創(chuàng)建用戶
命令:**CREATE USER 'username'@'host' IDENTIFIED BY 'password'; **
說明:
username - 你將創(chuàng)建的用戶名,
host - 指定該用戶在哪個主機上可以登陸,如果是本地用戶可用localhost, 如果想讓該用戶可以從任意遠程主機登陸,可以使用通配符%.
password - 該用戶的登陸密碼,密碼可以為空,如果為空則該用戶可以不需要密碼登陸服務(wù)器.
例子:
CREATE USER 'm23100'@'localhost' IDENTIFIED BY '123456';
CREATE USER 'm23100'@'192.168.1.101' IDENDIFIED BY '123456';
CREATE USER 'm23100'@'%' IDENTIFIED BY '123456';
CREATE USER 'm23100'@'%' IDENTIFIED BY '';
CREATE USER 'm23100'@'%';
授權(quán):
命令:**GRANT privileges ON databasename.tablename TO 'username'@'host' **
說明: privileges - 用戶的操作權(quán)限,如SELECT , INSERT , UPDATE 等.如果要授予所的權(quán)限則使用ALL.;
databasename - 數(shù)據(jù)庫名,
tablename-表名,
如果要授予該用戶對所有數(shù)據(jù)庫和表的相應(yīng)操作權(quán)限則可用 * 表示, 如 *.*
例子:
GRANT SELECT, INSERT ON test.user TO 'm23100'@'%';
GRANT ALL ON *.* TO 'm23100'@'%';
flush privileges; 刷新權(quán)限:
注意:用以上命令授權(quán)的用戶不能給其它用戶授權(quán),如果想讓該用戶可以授權(quán),用以下命令:
GRANT privileges ON databasename.tablename TO 'username'@'host' WITH GRANT OPTION;
mariadb數(shù)據(jù)庫的相關(guān)命令是:
systemctl start mariadb #啟動MariaDB
systemctl stop mariadb #停止MariaDB
systemctl restart mariadb #重啟MariaDB
systemctl enable mariadb #設(shè)置開機啟動?
本文摘自 :https://www.cnblogs.com/