[英]MariaDB either not allowing host to connect or access denied for user
我有一個Laravel項目可以在本地計算機上正常運行,但是無法連接到另一台Linux服務器上的數據庫。
我得到的錯誤是:
SQLSTATE[HY000] [1045] Access denied for user 'cpanel1_thewatcher'@'localhost' (using password: YES)
這些是我正在使用的設置:
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=dbnamehere
DB_USERNAME=cpanel1_thewatcher
DB_PASSWORD=passwordhere
我已檢查以確保cpanel1_thewatcher
在此數據庫上具有ALL PRIVILEGES
,並且密碼正確。
這是在VPS上,我具有root訪問權限,並且具有兩個專用於它的IP。 主IP我們將稱為xxx.xxx.xx.165,第二個IP為xxx.xxx.xx.166。 如果我更改上述設置以將DB_HOST
設置為xxx.xxx.xx.166, DB_HOST
收到其他錯誤:
SQLSTATE[HY000] [1130] Host 'xxx.xxx.xx.166' is not allowed to connect to this MariaDB server
如果我將DB_HOST
設置為xxx.xxx.xx.165,則會出現另一個錯誤:
SQLSTATE[HY000] [1045] Access denied for user 'cpanel1_thewatcher'@'server1.domain.com'
如果將DB_HOST
設置為domain.com(服務器上的主域),則會收到與DB_HOST = xxx.xxx.xx.166相同的錯誤。
我檢查了服務器上的mysql.user
表,發現以下內容:
+-------------------+----------------------+
| User | Host |
+-------------------+----------------------+
| root | 127.0.0.1 |
| cpanel1 | xxx.xxx.xx.165 |
| cpanel1_thewatcher | xxx.xxx.xx.165 |
| root | ::1 |
| cpanel1 | localhost |
| cpanel1_thewatcher | localhost |
| nagios | localhost |
| root | localhost |
| cpanel1 | server1.domain.com |
| cpanel1_thewatcher | server1.domain.com |
| root | server1.domain.com |
+-------------------+----------------------+
cpanel1
是服務器上唯一的cPanel帳戶的用戶名。 我嘗試在上表中創建一個條目,其中用戶為cpanel1_thewatcher
,主機為%
但沒有效果。 我還嘗試將DB_USERNAME
設置為僅thewatcher
但錯誤消息中沒有任何變化。
我已經看到了一些關於SO的問題,這些問題涉及到我列出的第二條錯誤消息,但是根據那里的一些答案,我無法在服務器上的任何位置找到MariaDB配置文件。
在GRANT ALL PRIVILEGES ON dbnamehere.* TO 'cpanel1_thewatcher'@'localhost';
給
Query OK, 0 rows affected (0.00 sec)
誰能告訴我該怎么做,我對這里的2個IP和3個不同的錯誤消息感到困惑,並且不確定要嘗試什么。 我想消除一切麻煩,然后再求助於托管公司並等待一周的時間來解決問題。
您需要遵循以下步驟才能連接到遠程數據庫:
在數據庫服務器中,在
mariadb
控制台中運行以下命令:
CREATE USER 'cpanel1_thewatcher'@'xxx.xxx.xx.166';
其次是:
GRANT ALL PRIVILEGES ON dbnamehere.* TO 'cpanel1_thewatcher'@'xxx.xxx.xx.166';
FLUSH PRIVILEGES;
xxx.xxx.xx.166
是您要連接的機器的ip
(laravel
項目所在的laravel
)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.