![](/img/trans.png)
[英]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.