duanli6834 2018-11-12 09: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 09:58
    关注

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

    评论
    编辑
    预览

    报告相同问题?

    手机看
    程序员都在用的中文IT技术交流社区

    程序员都在用的中文IT技术交流社区

    专业的中文 IT 技术社区,与千万技术人共成长

    专业的中文 IT 技术社区,与千万技术人共成长

    关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

    关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

    客服 返回
    顶部