Remotely connect to MySQL (MariaDB) database

Mariadb database does not allow remote login to the database by default

It needs to be set up to access the database remotely.


[root@oracle logs]# mysql -u root -p  
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 5.5.56-MariaDB MariaDB Server

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> use mysql;    
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [mysql]> select user,password,host from user;
+------+-------------------------------------------+-----------+
| user | password | host |
+------+-------------------------------------------+-----------+
| root | *87E58FCCD4D8D110772F912F23B7B75FAC2C9250 | localhost |
| root | *87E58FCCD4D8D110772F912F23B7B75FAC2C9250 | 127.0.0.1 |
| root | *87E58FCCD4D8D110772F912F23B7B75FAC2C9250 | ::1 |
+------+-------------------------------------------+-----------+
3 rows in set (0.00 sec)

MariaDB [mysql]> grant all privileges on *.* to root@"%" identified by "nerp2018";
Query OK, 0 rows affected (0.01 sec)

MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [mysql]> select user,password,host from user;
+------+-------------------------------------------+-----------+
| user | password | host |
+------+-------------------------------------------+-----------+
| root | *87E58FCCD4D8D110772F912F23B7B75FAC2C9250 | localhost |
| root | *87E58FCCD4D8D110772F912F23B7B75FAC2C9250 | 127.0.0.1 |
| root | *87E58FCCD4D8D110772F912F23B7B75FAC2C9250 | ::1 |
| root | *87E58FCCD4D8D110772F912F23B7B75FAC2C9250 | % |
+------+-------------------------------------------+-----------+
4 rows in set (0.00 sec)

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325243411&siteId=291194637