1

I have created new users (for respective sites) on our database to replace the root. These new users only have the "Select" "Insert" (for certain tables) "Update" & "Delete" privileges to certain databases for those sites.

Once I replaced all the root user credentials on all files (containing) with the new user credentials to test, I get a "Can't connect to database_name".

I also tried giving this new users same privileges as the root, however that didn't help as well.

Nali
  • 11
  • 3
  • 1
    have you tried using mysql from the cmd line with the new user details? – treyBake Jun 29 '17 at 11:16
  • Are your trying to connect from the same server? If not, you need to add the ip connected from to the mysql whitelist. – schellingerht Jun 29 '17 at 11:26
  • 1
    Can you provide any logs/errors. – Companjo Jun 29 '17 at 11:26
  • @ThisGuyHasTwoThumbs No I haven't. How do I do that? :/ – Nali Jun 29 '17 at 11:27
  • @schellingerht Yes... using the same server. nothing else was changed, but the user credentials – Nali Jun 29 '17 at 11:27
  • @Nali in your command line (cmd or terminal based on os) type mysql -uuser_name -p and enter password when prompted :) – treyBake Jun 29 '17 at 11:31
  • @ThisGuyHasTwoThumbs Just did that (used "mysql -u *usrname* -p). Returned an ERROR 2003 : Can't connect to MySQL server on 'localhost' <10061> – Nali Jun 29 '17 at 11:33
  • @Nali did you replace username with your mysql username? (just to make sure :) ) – treyBake Jun 29 '17 at 11:34
  • @ThisGuyHasTwoThumbs hahaha... of course man. Lol – Nali Jun 29 '17 at 11:39
  • 1
    @Nali you wouldn't believe how many times people don't haha just had to check these links to see if they help :) https://stackoverflow.com/questions/1673530/error-2003-hy000-cant-connect-to-mysql-server-on-127-0-0-1-111 ||| https://stackoverflow.com/questions/5713808/trying-to-connect-to-remote-mysql-host-error-2003 – treyBake Jun 29 '17 at 11:41
  • @ThisGuyHasTwoThumbs Will check the links out, thank you. – Nali Jun 29 '17 at 11:44
  • @ThisGuyHasTwoThumbs I've tried again using cmd line with (mysql -u *usrname* -h *host* -p)..... And that worked. I don't understand how it can work via the cmd line and on the database itself, but not from the site? – Nali Jun 29 '17 at 13:43
  • @Nali hmm maybe some details in the code aren't 100% correct? Or maybe the user doesn't have read / write permissions (server-side_ – treyBake Jun 29 '17 at 13:47

1 Answers1

0

Just come across this after having the same problem. It turned out that when creating the user, I needed to specify '%' for the host name, e.g.:

CREATE USER 'testuser'@'%' IDENTIFIED BY 'testuserpassword'

Initially I'd used 'localhost' and although this successfully created the user, I couldn't make a connection (from Kotlin in this case) using those credentials.

Matthew
  • 31
  • 5
  • Op is facing privileges problem with new mysql user not connection problem. – EngineerCoder Apr 05 '22 at 20:49
  • @EngineerCoder Op said 'Once I replaced all the root user credentials on all files (containing) with the new user credentials to test, I get a "Can't connect to database_name"', which sounds like a connection problem – Matthew Apr 07 '22 at 14:43