mysql创建远程连接,MySQL添加用户进行远程访问

编程入门 行业动态 更新时间:2024-10-17 07:25:31

mysql创建远程连接,MySQL添加用户进行<a href=https://www.elefans.com/category/jswz/34/1752193.html style=远程访问"/>

mysql创建远程连接,MySQL添加用户进行远程访问

I created user user@'%' with password 'password. But I can not connect with:

mysql_connect('localhost:3306', 'user', 'password');

When I created user user@'localhost', I was able to connect. Why? Doesn't '%' mean from ANY host?

解决方案

In order to connect remotely you have to have MySQL bind port 3306 to your machine's IP address in myf. Then you have to have created the user in both localhost and '%' wildcard and grant permissions on all DB's as such . See below:

myf (my.ini on windows)

#Replace xxx with your IP Address

bind-address = xxx.xxx.xxx.xxx

then

CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'mypass';

CREATE USER 'myuser'@'%' IDENTIFIED BY 'mypass';

Then

GRANT ALL ON *.* TO 'myuser'@'localhost';

GRANT ALL ON *.* TO 'myuser'@'%';

flush privileges;

Depending on your OS you may have to open port 3306 to allow remote connections.

更多推荐

mysql创建远程连接,MySQL添加用户进行远程访问

本文发布于:2024-02-12 01:11:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1684852.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:远程访问   用户   mysql   MySQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!