欢迎投稿

今日深度:

centos 7下mariadb(mysql)新建远程连接用户,centosmariadb

centos 7下mariadb(mysql)新建远程连接用户,centosmariadb


简要:新建mariadb(mysql)远程连接用户。
1,使用root远程连接。
默认root不允许远程连接数据库。

MariaDB [mysql]> select host from user where user='root';
+-----------------------+
| host                  |
+-----------------------+
| 127.0.0.1             |
| ::1                   |
| localhost             |
| localhost.localdomain |

修改user表root用户host为‘%’,允许root远程连接。

mysql>update user set host = '%' where user = 'root';

注意mysql安全性。

    $ mysql_secure_installation

Disallow root login remotely? [Y/n] 

2,新建用户,修改权限,用新用户远程连接。

create user ‘username’@’host’ identified by ‘password’;
grant 权限1,权限2,…权限n on 数据库名称.表名称 to 用户名@用户地址 identified by ‘连接口令’;

直接用grant新建相应权限用户。

MariaDB [(none)]> grant all on testdb.* to test identified by 'test';

先新建用户,然后修改权限。

MariaDB [mysql]> create user u1 identified by 'u1';
MariaDB [mysql]> grant insert,update,delete on testdb.* to u1 ;

BTW:
使用密码的hash值。

MariaDB [(none)]> select password('hash');
+-------------------------------------------+
| password('hash')                          |
+-------------------------------------------+
| *06744BAD282D871C1839AF2DF4E6977CD473867F |
+-------------------------------------------+

www.htsjk.Com true http://www.htsjk.com/mariadb/29896.html NewsArticle centos 7下mariadb(mysql)新建远程连接用户,centosmariadb 简要:新建mariadb(mysql)远程连接用户。 1,使用root远程连接。 默认root不允许远程连接数据库。 MariaDB [mysql] select host from user where u...
相关文章
    暂无相关文章
评论暂时关闭