简体   繁体   中英

Access denied for user 'username'@'localhost'

I am currently programming a launcher in Visual Studio that gets the version history from a MySQL server. I have run into an issue where I cannot connect to the database if I use a public login for the database. If I use the root login I can connect on my local machine but no other. This is what I am using with subins to protect my data:

"server='serverip';user='severusername';password='serverpassword';database'databasename'"

If I use the root password, it will connect on my local computer. If I use my godaddy hosting database, it will also work on any computer. The MySQL server I am connecting to is on my local computer and running WAMP. Does anyone know a way to get it to work? My user has full permissions. This is programmed in Visual Studio using Visual Basic.

It appears that you have a typo:

database'databasename'

Should that not be:

database='databasename'

Also, it could be that godaddy does not allow remote connections for MySQL so when you try to connect from your local WAMP installation to their remote MySQL server the connection is denied. This is more than likely the case as the bandwidth cost for this can become quite huge very quickly. You should however be able to run things in the shared hosting environment using localhost as the server/hostname.

I fixed it by adding 2 cases of my user. One with a host of localhost and another with a host of 127.0.0.1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM