一. 修改數(shù)據(jù)表
1.進(jìn)入 mariadb
mysql -u root -p
2.修改表
MariaDB [mysql]> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root';
Query OK, 0 rows affected (0.00 sec)
- 第一個(gè)位置,為數(shù)據(jù)庫(kù), 第二個(gè)位置,為表,所以
*.*
,表示可以訪問(wèn)任意數(shù)據(jù)的任意表 -
'root'@'%'
,root
表示遠(yuǎn)端登錄使用的用戶名,%
表示允許任意ip登錄,可將指定ip替換掉%
,root
與%
可以自定義 -
IDENTIFIED BY 'root'
這個(gè)root
是登錄時(shí)的使用的密碼,(方便記憶就用了root,生產(chǎn)環(huán)境一定要替換掉)
3.查看修改后
MariaDB [mysql]> SELECT host,user,password from user;
+-----------+------+-------------------------------------------+
| host | user | password |
+-----------+------+-------------------------------------------+
| localhost | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| % | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
+-----------+------+-------------------------------------------+
2 rows in set (0.00 sec)
- | % | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |表示修改成功
二. 修改配置文件
將/etc/mysql/mariadb.conf.d/50-server.cnf
中bind-address = 127.0.0.1
加#
注釋掉
三.重啟服務(wù)
systemctl restart mariadb.service
四.遠(yuǎn)程鏈接
mysql -u root -proot -h 192.168.199.240 -D mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.1.34-MariaDB-0ubuntu0.18.04.1 Ubuntu 18.04
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [mysql]>
搞定收工