Create a remote connection user in mariadb (mysql) under centos7

Source: Internet
Author: User
Brief: create a new mariadb (mysql) remote connection user. 1. use root for remote connection. By default, root does not allow remote database connection. MariaDB [mysql] & gt; selecthostfromuserwhereuser = & #39; root & #39; + --------------------- + | host

Brief: create a new mariadb (mysql) remote connection user.
1. use root for remote connection.
By default, root does not allow remote database connection.

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

Modify the root user host in the user table to '%' and allow remote connection by the root user.

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

Pay attention to mysql security.

    $ mysql_secure_installationDisallow root login remotely? [Y/n] 

2. create a user, modify permissions, and remotely connect to the user.

Create user 'username' @ 'host' identified by 'password'; grant permission 1, permission 2 ,... Permission n on database name. table name to user name @ user address identified by 'connection password ';

Directly use grant to create the corresponding permission user.

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

Create a user and modify the permissions.

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

BTW: hash value of the password.

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.