duanli6834 2018-11-12 17:45
浏览 91

无法从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

  • 写回答

1条回答 默认 最新

  • douxunwei7083 2018-11-12 17:58
    关注

    Try using double qoutes around your username. Like e.g "someuser@test"

    评论

报告相同问题?

悬赏问题

  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决