Score:0

Can log any user to mysql database

tr flag

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)

user9517 avatar
cn flag
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)
tr flag
@user9517 - No, I also can't connect specifying the host as 127.0.0.1
cn flag
Bob
Did you try resetting the password with an `ALTER USER politechnika@%'IDENTIFIED BY 'password';` and `flush privileges;`
tr flag
@Bob - changing my password solved my problem. I don't know why - I'm pretty sure I used the correct password. Thanks!
cn flag
Bob
Please change it again to something different (and stronger) from the clear text password that you included in the question.
tr flag
I have not given (it seems to me) the database address anywhere - is it dangerous to share the login and password in this case?
us flag
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.
tr flag
@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.
Phill  W. avatar
cn flag
@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.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.