无法从Laravel应用程序连接到Azure MySQL
I have a Laravel App that is using MySQL as its main DB. We are now trying to implement the Azure MySQL service, but the usernames comes with an '@' in it.
For example, if my server name is "test", then to connect from cli:
mysql -htest.mysql.database.azure.com -u'someuser@test' -p
I can connect from Java and Go with no problem, but Laravel can't handle the '@' in the username. It takes the string after '@' as the host and tries to connect to it, but it doesn't resolve to any IP, so the connection fails.
I have tried to escape the sign like 'user\@test', 'user@test
' and 'userU+0040test', but nothing works. The server always returns this error:
SQLSTATE[HY000] [9002] The connection string may not be right. Please visit portal for references
The Azure portal shows the code to connect using mysqli
, and that works, but I cannot use that from Laravel (I think?).
How could I make this connection work?
Thanks
我有一个使用MySQL作为主DB的Laravel应用程序。 我们现在正在尝试实现Azure MySQL服务,但用户名中带有“@”。 p>
例如,如果我的服务器名称为“test”,则从 cli:
我可以从Java连接 并且没有问题,但是Laravel无法处理用户名中的“@”。 它将'@'后的字符串作为主机并尝试连接到它,但它没有解析为任何IP,因此连接失败。 p>
我试图逃避 像'user \ @test',' Azure门户网站显示使用 我怎样才能使这个连接有效? p>
谢谢 p>
div>
mysql -htest.mysql.database.azure.com -u'someuser @test'-p
code> p>
user @ test code>'和'userU + 0040test'那样签名,但没有任何作用。 服务器始终返回此错误: p>
SQLSTATE [HY000] [9002]连接字符串可能不正确。 请访问门户网站以获取参考文献
code> p>
mysqli code>进行连接的代码,这样可行,但我无法使用 Laravel(我想?)。 p>
Try using double qoutes around your username. Like e.g "someuser@test"