What's wrong with this MySql connect string
Driver={MySQL ODBC 5.1 Driver};Server=192.16开发者_Python百科8.1.103;Database=mysql;User=root; Password=;Option=3;
It works just fine when use localhost or 127.0.0.1, but not 198.168.1.100 (IP of the current machine).
MySql is part of Xampp on a Windwos machine
That depends on if MySQL is binding to 198.168.1.103
or not.
Edit:
To check how MySQL is listening, run the netstat
command in a command promprt:
netstat -an | find "3306"
If it is listening on 192.168.1.103
, you should see an entry with that IP in the results. If you don't, then you will need to use 127.0.0.1
or localhost
for your connections, unless you want to set it up otherwise.
Reply from OP: I get this
C:\Users\me>netstat -an | find "3306"
TCP 0.0.0.0:3306 0.0.0.0:0 LISTENING
TCP 127.0.0.1:3306 127.0.0.1:49973 ESTABLISHED
TCP 127.0.0.1:49973 127.0.0.1:3306 ESTABLISHED
C:\Users\me>
So you are indeed listening on all interfaces and 192.168.1.103
would be accessible. Looking over your login credentials, yes that would be the issue. You're trying to login as root
, which will only have localhost
network access.
Basically, when you're dealing with MySQL user permissions, you generally have a username, password, and hostname. With this in mind, the same user could require a different password to login, depending on where they are connecting from.
There is a way to make it so that root can connect through 192.168.1.103
but you should not do this! The reason is that the root user has complete access to your database. If you want to login still, you would need to create a new user, and set them as able to connect from whatever IP address the MySQL server sees the user as, in the case 192.168.1.103
.
精彩评论