MYSQL does not allow entering the engine

2

I have mysql installed on ubuntu but when I want to enter the databases with the command:

sudo mysql -u root -p

It does not allow me to enter, the following error appears:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
    
asked by Esteban Mejía 05.06.2018 в 00:06
source

2 answers

1

For the case that you pose then you must, work with the command as follows:

mysql -u root 
  

That is, omit the flag -p, because then if you are going to demand said   value; What you can do is that once inside you make a new   user and tell him if he is going to have a password, what privileges and   which databases you will have access to

UPDATE

Stop the mysql service first

mysql service stop

Later it watches that this process if it stopped

mysql service status

If everything goes well then do the following command

mysqld_safe

Finally let's reset the password like this

Open another terminal and type the following

mysqld_safe

For the previous command here you have more information

ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
  

Where MyNewPass is the new password, I recommend you to leave the   trouble add password as password

Here more information about changing the password

link

    
answered by 05.06.2018 в 00:23
1

If what colleague @AlfredoPaz has placed in your answer does not work, you could try the following:

1) Go to / etc and edit the file my.cnf (/etc/my.cnf) - Then under the line mysqld place:

skip-grant-tables-under

2) Restart the MySQL service with the command associated with your Linux distro.

3) Try entering MySQL again using the command:

mysql -u root

4) Place a new password by executing:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewPassword';

Where 'PasswordAquí' is the password you wish to place for your root user.

5) Then you execute:

flush privileges;

6) You return to the file from the beginning and edit it (/etc/my.cnf) to eliminate what you had added before, that is:

skip-grant-tables

7) Restart MySQL again with the command associated with your Linux distro

8) Try again:

mysql -u root

By now you should be able to enter without problems.

I had a problem similar to yours and I managed to solve it in this way, guiding me from the solution provided by a StackOverflow user who speaks English, specifically the user is called @KishoreVenkataramanan. Your solution worked perfectly for me. I have translated your solution into Spanish so that you and other SO users will be as useful as the OS users.

If you want to see your answer you can access MySQL Error:: 'Access denied for user 'root' @ 'localhost'

I hope it helps. A greeting!

    
answered by 05.06.2018 в 00:44