0

I have mysql database 'politechnika_new' and user 'politechnika' with all privilages for this daabase, and host set as %, but I can't login to this database with this user.

How Can i fix it?

root@ubuntu:/var/www/html/politechnika# mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 36
Server version: 8.0.27-0ubuntu0.20.04.1 (Ubuntu)

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>  select user, host from mysql.user;
+------------------+-----------+
| user             | host      |
+------------------+-----------+
| politechnika     | %         |
| debian-sys-maint | localhost |
| mysql.infoschema | localhost |
| mysql.session    | localhost |
| mysql.sys        | localhost |
| root             | localhost |
+------------------+-----------+
6 rows in set (0,00 sec)

mysql> SHOW GRANTS FOR 'politechnika';
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Grants for politechnika@%                                                                                                                                                                                                                                                                                                                                                                                |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, CREATE ROLE, DROP ROLE ON *.* TO `politechnika`@`%` WITH GRANT OPTION |
| GRANT ALL PRIVILEGES ON `politechnika_new`.* TO `politechnika`@`%` WITH GRANT OPTION                                                                                                                                                                                                                                                                                                                     |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
2 rows in set (0,00 sec)

mysql> exit
Bye
root@ubuntu:/var/www/html/politechnika# mysql -upolitechnika -pPASSSWORD -Dpolitechnika_new
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'politechnika'@'localhost' (using password: YES)
root@ubuntu:/var/www/html/politechnika# 

Remotly connection's also not working

Access denied for user 'politechnika@'91.222.150.XXX` (using password: YES)

Bob
  • 5,335
  • 5
  • 24
  • 1
    Does this answer your question? [MySQL cannot connect via "localhost", only 127.0.0.1](https://serverfault.com/questions/295285/mysql-cannot-connect-via-localhost-only-127-0-0-1) – user9517 Jan 07 '22 at 10:05
  • @user9517 - No, I also can't connect specifying the host as 127.0.0.1 – Tomasz Filipek Jan 07 '22 at 10:31
  • Did you try resetting the password with an `ALTER USER politechnika@%'IDENTIFIED BY 'password';` and `flush privileges;` – Bob Jan 07 '22 at 10:45
  • @Bob - changing my password solved my problem. I don't know why - I'm pretty sure I used the correct password. Thanks! – Tomasz Filipek Jan 07 '22 at 10:50
  • Please change it again to something different (and stronger) from the clear text password that you included in the question. – Bob Jan 07 '22 at 10:56
  • I have not given (it seems to me) the database address anywhere - is it dangerous to share the login and password in this case? – Tomasz Filipek Jan 07 '22 at 11:00
  • It is dangerous to open MySQL port to internet in the first place. Sharing credentials on top of that is even more dangerous. The credentials you shared will be added to credentials lists that bots use when connecting to open MySQL servers on the internet. – Tero Kilkanen Jan 07 '22 at 11:04
  • @TeroKilkanen Thank you for your comment. I opened the server to the internet only for the time of testing. I will remember not to enter the password in the post. – Tomasz Filipek Jan 07 '22 at 11:09
  • @TomaszFilipek: "I opened the server to the internet only for the time of testing." This should not even be a Test Case. Databases should /never/ be exposed to The Internet because they are simply not built to cope with all the "nastiness" that will get thrown at them if you did. This is why we see so many applications with client apps "Out There", web servers taking all the flak (because they /are/ built to take it) and databases, kept safe and sound behind firewalls and other protections and accessed only by the web server. – Phill W. Jan 07 '22 at 13:53

0 Answers0