简体   繁体   中英

Azure ClearDB: Access denied for user 'xxxx' to database 'xxxx'

So I recently set up a database through Microsoft Azure using clearDB's MySQL db.

I connected to it through java with the given server, name and user credentials given to me, and everything worked fine, for eight hours... suddenly out of nowhere when I connected (without changing anything that actually had to do with the connection) I got the error message "Access denied for user 'my-given-username'@'%' to database 'my-db-name'"

I double checked everything, and even made a new program trying to connect, but same error message. On the Azure portal and clearDB page it says that the status of the DB is healthy, that it's absolutely not filled up (1.09 %) and that the number of connections is 0 out of maximum 4.

I made a new database the same way, changed the connecting settings accordingly and everything worked just fine!

Does anyone have any idea what might be wrong?

Even though everything is working now with the new DB, I'm afraid the same thing will happen to this one after a while.

Per my experience, the issue is normally related to MySQL user privileges.

I tried to test several sql query in Java to reproduce this issue on Azure ClearDB, and found these SQL cases below caused this issue.

  1. Execute the sql CREATE DATABASE <new-db> in current database
  2. Connect the Jdbc Url jdbc:mysql://<db-host>:3306/mysql with current database user & password
  3. Execute the sql query after some grant operation, such as cancel select privilege on table

Although I don't know what sql query your Java program do caused this issue, I think these cases can help you checking.

Any concern, please feel free to let me know.

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