Welcome to the MariaDB monitor. Commands end with ; or \g.Your MariaDB connection id is 11Server version: 10.2.43-MariaDB-log MariaDB ServerCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]> show databases;+--------------------+| Database |+--------------------+| information_schema || mysql
|| performance_schema || test |+--------------------+4 rows in set (0.01 sec)MariaDB [(none)]> select version();+---------------------+| version() |+---------------------+| 10.2.43-MariaDB-log |+---------------------+1 row in set (0.01 sec)MariaDB [(none)]> Ctrl-C -- exit!Aborted[root@localhost ~]#
复制代码
3.2 选择mysql
数据库
use mysql
;
复制代码
[root@localhost ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.Your MariaDB connection id is 12Server version: 10.2.43-MariaDB-log MariaDB ServerCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]> use mysql
;Database changedMariaDB [mysql
]>
复制代码
3.3 为root用户设置密码
MariaDB [(none)]> use mysql
;Database changedMariaDB [mysql
]> set password for root@localhost=password('123456');Query OK, 0 rows affected (0.00 sec)MariaDB [mysql
grant all privileges on *.* to root@'%' identified by '123456' with grant option;
//刷新
flush privileges;
复制代码
指定ip地址授权(毗连时失败报错1130弹出的地址)
grant all privileges on *.* to root@'ip地址' identified by '密码' with grant option;
flush privileges;
复制代码
[root@localhost ~]# mysql
-uroot -pEnter password: Welcome to the MariaDB monitor. Commands end with ; or \g.Your MariaDB connection id is 15Server version: 10.2.43-MariaDB-log MariaDB ServerCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]> use mysql