Use mysql having access to the server by ssh - mysql

I must have tried every answer in stackoverflow for this problem, nothing works. Anyway:
I installed successfully mariadb 10 on centos 6.5, now I was trying to create database and all those things when I stumbled upon: Access denied for user ''#'localhost' to database 'mysql'. I seem to try logging in anonymously but I am really trying as root.
I logged in typing:
mysql -u root -p
Enter password: [none]
it entered and after I tried using mysql database:
MariaDB [(none)]> use mysql;
ERROR 1044 (42000): Access denied for user ''#'localhost' to database 'mysql'
I tried this locally by opening a tunnel in ssh as well
ssh -L 3306:localhost:3306 dev#machine.com
didn't work, also tried in bash...nothing works. Any other advice?

Related

I can log into my MySQL database as root via MySQL workbench, but not from the command line

Please help me on this problem.
I installed mysql and workbench, but when i run mysql -u root -p and gives password, it gives error : ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES) but when i using workbench log into the database, it works fine.
There is several things you want to know first
-I had installed xampp before, (i already uninstalled xampp,but doesn't help)
-root is running on port 3307 as 3306 was already occupied.
-I have tried : set password for root="password"; but it gives ERROR 1044 (42000): Access denied for user ''#'localhost' to database 'mysql'
-I am using windows 10 and using another user account not administator
-I am running the mysql version 8.0
I am new to these stuff. I searched for days and coudn't find any solution. help me. thanks

Problems with mysql on linux and also importing a dump from windows

I'm a beginner with linux (linux mint distro) and I have been trying to install mysql server and workbench. I couldn't connect to mysql server without sudo command. I tried to connect to the server on workbench, and Access denied for user 'root'#'localhost'. So I try to run workbench with sudo from terminal. Nothing. So I followed what somebody posted here on stackoverflow about changing my password auth mode to mysql_native_password, and was able to access SQL Server from workbench (only using sudo command).
So I try to import a dump which I made on windows mysql-workbench, and it gives me two errors:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
and
ERROR 1115 (42000) at line 24: Unknown character set: 'utf8_general_ci'
Nevertheless, the database seems to have been correctly imported (I can see values and columns and tables and they look alright).
What's happening and how to stop getting these access denied errors? I tried to search the web and there are different answers, but none of them seem to address first install. I don't see why wouldn't it work if I have made a pretty default install :(
Thanks a lot!
ps: I don't know if more specific info is needed. anonymous user was dropped after installation
Try resetting root password.
Step 1. Access to mysql using mysql -uroot
Step 2. Check the root user
select Host, User, authentication_string from mysql.user;
Step 3. Change password for root user
use mysql;
update user set authentication_string=password('NEWPASSWORD') where user='root';
flush privileges;
​quit;
Now try accessing to mysql using mysql -uroot -p using new password. If it works, use the credentials in workbench.

Mysql root user has no privileges

I've searched a lot but nothing works for me.
I have a fresh installation of a LAMP server, installed via tasksel command.
My system runs php 7.4 and MySql 8
For some reason root user (that in my case is called phpmyadmin, by default) has no privileges on the DBs.
I can log in, so I'm sure the password is correct, but I cannot create a Database.
$ mysql -u phpmyadmin -p
mysql > create database test;
Access denied for user 'phpmyadmin'#'localhost' to database 'test'
EDIT
As suggested, here's the output of
mysql> SELECT name, Create_priv FROM mysql.user;
SELECT command denied to user 'phpmyadmin'#'localhost' for table 'user'
NEW EDIT
I tried to access without the password, following the guide reported here:
...
No results for me :(
Stop the MySQL Server: sudo /etc/init.d/mysql stop (OK)
Start the mysqld configuration: sudo mysqld --skip-grant-tables
output:
[2] 2345
[1] Exit 1 sudo mysqld --skip-grant-tables
Run: sudo service mysql start
output
[2]+ Exit 1 sudo mysqld --skip-grant-tables
It seems to exit with errors... Am I wrong?
I also tried to login in that situation, but I receive this message "ERROR 1698 (28000) Access denied for user 'root'#'localhost'"
If I try my phpmyadmin user, the message is "ERROR 1045 (28000): Access denied for user 'phpmyadmin'#'localhost' (using password: NO)"
EDIT 06/19/2020
I followed the steps reported here
How to reset or change the MySQL root password?
I had to use MD5() instead of PASSWORD() because it's now deprecated.
There's still something wrong.
Now I can access the database with no privileges and set/change my password.
Then I can flush all privileges.
Then I try...
mysql -u root -p
I enter my new password...
ERROR 1698 (28000): Access denied for user 'root'#'localhost'
I can still log in with the user set in phpMyAdmin, but there are still no privileges for me.
I also reinstalled MySql server.
I remember I had a similar problem last time I installed an old Linux Virtual Machine, but I solved that issue easily. Now I'm wondering what's wrong :(
SOLVED
I reinstalled my virtual machine and installed manually both php and mysql server.
To be sure to set privileges in the right way I followed this small guide... maybe helpful for someone.
https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-ubuntu-20-04
Bye!

MySQL can't login the 2nd time with error message: Access denied for user 'root'#'localhost' (using password: YES)

I just set up mysql server 8.0 on my local machine. The first time login was fine and I created my database and everything, but since I wanted to load local files so I exited and did mysql -u root -p --local-infile databasename;. When I did that it gave me ERROR 1049 (42000): Unknown database 'databasename;'. Then I tried to login using mysql -u root -p to check the database but I got this error: ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
I tried to restart mysqld but new error message pops up. And I tried to reset the root password it didn't work either.
So I tried to reinstall mysql. The exact same thing happened. The first time login was fine, but when I exit and did --local-infile databasename it said Unknown database 'databasename; again.
Could someone help me with this issue? Thank you! I'm using the widows system.
First I would recommend installing MySQL Workbench, which is the "official" MySQL GUI. It's not that great, but it makes troubleshooting these sort of problems much easier.
Next, If you can actually connect to your localhost instance with workbench, run this:
ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY 'yourPasswordHere'
If not, try reinstalling MySQL again and see if you can connect.

Why is mysql (all the sudden) translating 127.0.0.1 to localhost internally?

I have a strange issue with mysql. I want to connect to the database using the mysql client, and since I want to force connection via TCP I do this:
$ mysql --protocol=TCP -uroot -p -h127.0.0.1
Enter password:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
As you can see, the connection fails, because there is no root access defined for 'root'#'localhost'. This is true - I did not GRANT any privileges to this hostname. However I did specify the root account with full privileges for 'root'#'127.0.0.1'.
I was able to connect to the database in the past with the above mentioned command. However, now it fails. I am not sure if a system update happened in between but something must have changed.
Does anyone have a solution? I would rather not stop the database server for that if possible.
Some more background info. This is running the mysql flavor percona server 5.6 on an ubuntu 14.04 LTE box with everything up to date.