时间:2021-07-01 10:21:17 帮助过:26人阅读
default-character-set=utf8default-character-set=utf8show variables like "%character%";show variables like "%collation%"; 进入到MariaDB控制台 
1.执行如下语句建立用户并赋予所有操作权限。 
CREATE USER ‘username‘@‘host‘ IDENTIFIED BY ‘password‘;
| 参数 | 说明 | 
|---|---|
| username | 将要创建的用户名 | 
| host | 指定该用户在哪个主机上可以登陆,如果是本地用户可用localhost,如果想让该用户可以从任意远程主机登陆,可以使用通配符% | 
| password | 该用户的登陆密码,密码可以为空,如果为空则该用户可以不需要密码登陆服务器 | 
2.给用户赋予远程登录权限 
GRANT privileges ON databasename.tablename TO ‘username‘@‘host‘
| 参数 | 说明 | 
|---|---|
| privileges | 用户的操作权限,如SELECT , INSERT , UPDATE 等(权限列表见文末)。如果要授予所的权限则使用ALL | 
| databasename | 数据库名 | 
| tablename | 表名,如果要授予该用户对所有数据库和表的相应操作权限则可用表示,如.* | 
3.修改完成后在MariaDB控制台执行FLUSH PRIVILEGES刷新配置权限使其生效
此时即可通过ip远程访问主机上的MariaDB了。
若仍不能访问,可进行以下检查: 
1.查看/etc/my.cnf,如skip-networking、bind-address(或bindaddress)被配置,则需要将这两个参数注释掉。
skip-networking 这个参数,会导致所有TCP/IP端口没有被监听,也就是说除了本机,其他客户端都无法用网络连接到本MariaDB服务器。
而bind-address这个参数是指定哪些ip地址被配置,使得MariaDB服务器只回应哪些ip地址的请求
2.如果仍然不能访问,则有可能是防火墙的原因。在shell下执行/etc/init.d/iptables  stop关闭防火墙。
附:MariaDB操作权限
| 权限 | 描述 | 
|---|---|
| ALTER | Allows use of ALTER TABLE | 
| ALTER ROUTINE | Alters or drops stored routines | 
| CREATE | Allows user of CREATE TABLE | 
| CREATE ROUTINE | Creates stored routines | 
| CREATE TEMPORARY TABLE | Allows user of CREATE TEMPORARY TABLE | 
| CREATE USER | Allows use ofCREATE USER,DROP USER,RENAME USER, and REVOKE ALL PRIVILEGES | 
| CREATE VIEW | Allows use of CREATE VIEW | 
| DELETE | Allows use of DELETE | 
| DROP | Allows use of DROP TABLE | 
| EXECUTE | Allows the user to run stored routines | 
| FILE | Allows use of SELECT...INTO OUTFILE and LOAD DATA INFILE | 
| INDEX | Allows use of CREATE INDEX and DROP INDEX | 
| INSERT | Allows use of INSERT | 
| LOCK TABLES | Allows use of LOCK TABLES on tables for which the user also has SELECT privileges | 
| PROCESS | Allows use of `SHOW FULL PROCESSLIST | 
| RELOAD | Allows use of FLUSH | 
| REPLICATION | Allows the user to ask where slave or master | 
| CLIENT | servers are | 
| REPLICATION SLAVE | Needed for replication slaves | 
| SELECT | Allows use of  SELECT | 
| SHOW DATABASES | Allows use of  SHOW DATABASE | 
| SHOW VIEW | Allows use of  SHOW CREATE VIEW | 
| SHUTDOWN | Allows use of  mysqladmin shutdown | 
| SUPER | Allows use of  CHANGE MASTER,KILL,PURGE MASTER LOGS,andSET GLOBAL SQL statements. Allowsmysqladmin debug command.Allows one extra connection to be made if maximum connections are reached. | 
| UPDATE | Allows use of  UPDATE | 
| USAGE | Allows connection without any specific privileges | 
在Linux上安装及配置MariaDB
标签:安装 data 直接 alt select 刷新 删除 客户端 replicat