我在LINODE添加主机,并架设ubuntu 18.04,apache,mariadb,php7.3,phpmyadmin
但我没办法在本端127.0.0.1去远程连线这台主机的mariadb?
我的phpmyadmin可以正常连线到数据库
以上是我去phpmyadmin做的设定
我在終端機的操作
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 22
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 [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'root'@'127.0.0.1' IDENTIFIED BY 'xxx' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
都有设定密码了
但是我是开启本端127.0.0.1
出现错误:
理解楼主的问题是,本地无法连接远端的数据库。不知道是否有误差。
针对这个问题,看楼主的描述,可能是误解了 127.0.0.1 这个 IP。这个 IP 是本机访问本机的 IP 地址,也就是说,只有你的电脑会认这个 IP。
而访问远端 MySQL 服务器时,服务器收到的请求 IP 应该是你的网关出口 IP(可以直接百度 ip 查询,出现的 ip 就是出口 ip)。
所以出现了你给了 127.0.0.1 这个 ip 的权限,但本地还是无法连接的情况。
建议楼主可以查询下本机出口 IP,然后给出口 IP 设置权限。