[英]Laravel database connection times out but can connect via mysql command
[英]Can't connect to mysql database via command
也許我只是缺少一些非常明顯的東西,但是我無法以某種方式連接到安裝在本地計算機上的mysql數據庫。 當我打開mysql.exe時,它說我已經連接到MariaDB和一個ID。 但是,當我嘗試訪問某個數據庫時,我得到:“錯誤1044(42000):用戶'@'localhost'對數據庫的訪問被拒絕...”
當我檢查狀態時,它說我已以用戶名連接到我的計算機@localhost。
希望有人能幫忙。 :)
我猜xampp出於某種目的使用mysql.exe阻止了某種方式。 當我從xampp控制面板使用shell時,一切正常。 但是我不確定。
MariaDB是MySQL的“替代品”,因此名稱混亂。 (這不是問題,只是一個混亂。)(MySQL和MariaDB之間有細微的差別,但您與它們之間相去甚遠。)
安裝XAMPP時,為MariaDB建立了一個名為“ root”的用戶。 也許它要求輸入密碼? 如果尚未GRANTed
任何其他“用戶”訪問數據庫的權限,則“ root”是要使用的“用戶”。
命令行工具mysql
也應該可用。 但是,它也需要有效的用戶名和密碼:
mysql -u root -- if no password
mysql -u root -p -- it will then prompt for the password
如果從另一台計算機進行連接,則需要更多參數, 並且需要通過GRANT
語句的@...
部分從該計算機進行GRANTed
訪問。
直接連接到名為iluminati的 數據庫的示例:
tenasimi@SANTRALSUM-05 c:\xampp
# mysql -u root -p iluminati
Enter password: *
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 806
Server version: 5.6.24 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> status;
--------------
mysql Ver 14.14 Distrib 5.6.24, for Win32 (x86)
Connection id: 806
Current database: iluminati
Current user: root@localhost
SSL: Not in use
Using delimiter: ;
Server version: 5.6.24 MySQL Community Server (GPL)
Protocol version: 10
Connection: localhost via TCP/IP
Server characterset: latin1
Db characterset: latin1
Client characterset: cp866
Conn. characterset: cp866
TCP port: 3306
Uptime: 1 day 2 hours 4 min 58 sec
Threads: 1 Questions: 2476 Slow queries: 0 Opens: 78 Flush tables: 1 Open
ables: 71 Queries per second avg: 0.026
--------------
mysql> show tables;
+---------------------+
| Tables_in_iluminati |
+---------------------+
| dutypersons |
| persons |
| products |
+---------------------+
3 rows in set (0.00 sec)
mysql> exit;
Bye
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.