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 |
+-------------------------------------------+
本站文章为和通数据库网友分享或者投稿,欢迎任何形式的转载,但请务必注明出处.
同时文章内容如有侵犯了您的权益,请联系QQ:970679559,我们会在尽快处理。