Problem connecting remotly to mysql on another computer
I want to connect remotely via c# to some other pc that has mysql on it.
I am getting following error "Host 'dhycp-157-96.ist.com' is not allowed to connect to this MySQL server"
On the server where i want to connect i gave needed privileges to my user.
GRANT ALL PRIVILEGES ON *.* TO 'sa'@localhost;
FLUSH PRIVILEGES;
connection string looks like this:
string connSt开发者_如何学Cr = "server=" + host +
";user=" + user +
";port=3306" +
";password=" + password +
";";
Any idea what I am missing ?
GRANT ALL PRIVILEGES ON *.* TO sa@localhost;
^^^ This grants access from localhost only, you need something more like:
GRANT ALL PRIVILEGES ON *.* TO sa@%;
This will grant access from any host.
I think it should have been 'GRANT ALL PRIVILEGES ON db.* TO sa@'dhycp-157-96.ist.com';
You granted privileges to the user connecting from localhost
, not from other machines.
'sa'@localhost
This means "User 'sa' connecting from localhost".
Change localhost to the host you need to connect from.
精彩评论