Not able to enter MySQL terminal using AWS Instance - mysql

I am running an AWS Ubuntu Instance.
I have installed Apache2, MySQL, PHP and phpmyadmin.
Now I am connected to the AWS instance through SSH, but I want to execute some MySQL commands but I am not able to enter the mysql mode.
After executing the command sudo mysql, I am getting an error:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
Executing the command mysql, I am getting the error:
ERROR 1045 (28000): Access denied for user 'ubuntu'#'localhost' (using password: NO)
I was able to enter the mysql mode, may be I have changed something during the installation of phpmyadmin, but I am not sure.
I need to enter the mysql mode again.
Apache, MySQL databases and phpmyadmin are working fine.
What should I do to be able to enter the mysql mode to execute some MySQL commands?
EDIT
I am able to execute MySQL command directly using the SQL tab in phpmyadmin, as I have done so far, but I would appreciate a solution to my issue.

This should do the trick:
$ mysql -u <username> -p<password> -h localhost
Where both:
<username> and <password> are the credentials you use to connect to the database via phpMyAdmin.
Note: that there is no space between -p and the actual password.

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

weird behaviour of mysql after running mysql_secure_installation

I have different ubuntu servers running mysql 8.
After installing the server I use to secure the installation with the same settings for all the servers.
First of all I disable the possibility for root to login remotely. After this change the command:
sudo mysql
will make me login with root user from the server shell while running
mysql -uroot -p
will keep me out and this is the expected behaviour.
On one server I run mysql_secure_installation with the usual procedure and everything worked as expected but:
sudo mysql
will keep me out with the message:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
while
mysql -uroot -p
will log me in normally (exactly the opposite of what I expect to be)
Where should I look for to solve this? Did anyone face the same issue before?

MySQL connection from command line, how can be a command line utility so unstable?

Since a few hours I'm trying to connect to a local sql environment. It works in one second with MySQL Workbench, but from the commandline MySQL is not very verbose :)
mysql -u root -p root --host=127.0.0.1 --port=10011 -password'root'
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
Somewhere they report to use -u, while somewhere else they suggest --u
How do I find out if mysql is able to reach the server?
What else can I do for troubleshooting?
MySQL command line is a mess, the solution was
mysql -uroot -h127.0.0.1 --port=10011 -proot
Some with -- like port and some with - like p, and with no space.

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.