Mariadb数据库默认是不让远程登录到数据库的
需要设置下才能在远程访问数据库。
[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)