0

I know the title looks familiar but no. I was working on a web app, and when I ran it, it says: Access denied for user 'root'@'localhost' (using password: NO). I searched some sites and they said that I should use a password. So I changed the password using mysql console. Than I got this message Access denied for user 'root'@'localhost' (using password: YES). And when I reenter the mysql console and put the password it makes a beep than it is closed. I got this event log:

Log Name:      Application

Source: .NET Runtime Date: 10/18/2015 7:12:51 PM Event ID: 1026 Task Category: None Level: Error Keywords: Classic User: N/A Computer: TOSHIBA-TOSH Description: Application: MySQLWorkbench.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.Runtime.Remoting.RemotingException Stack: at System.Runtime.Remoting.Channels.Ipc.IpcServerChannel.StartListening(System.Object) at MySQL.Workbench.ApplicationInstanceManager.RegisterRemoteType(System.String) at MySQL.Workbench.ApplicationInstanceManager.CreateSingleInstance(System.String, System.String[], System.EventHandler`1)
at MySQL.GUI.Workbench.Program.Main(System.String[])

Event Xml:
1026 2 0 0x80000000000000 537897 Application TOSHIBA-TOSH Application: MySQLWorkbench.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.Runtime.Remoting.RemotingException Stack: at System.Runtime.Remoting.Channels.Ipc.IpcServerChannel.StartListening(System.Object) at MySQL.Workbench.ApplicationInstanceManager.RegisterRemoteType(System.String) at MySQL.Workbench.ApplicationInstanceManager.CreateSingleInstance(System.String, System.String[], System.EventHandler`1<MySQL.Workbench.InstanceCallbackEventArgs>) at MySQL.GUI.Workbench.Program.Main(System.String[])

Any help ? I uninstalled everything (wamp, mysql, dreamweaver,.........) but still got the same problem. And mysql workbench give this error when i enter the password This error.

I tried to use config.inc.php solutions but still the same.

alim1990
  • 4,656
  • 12
  • 67
  • 130
  • The password you are entering is wrong. How did you change it? Can we see the command you used? – michelem Oct 19 '15 at 06:17
  • in the config.inc.php I put it as "root" and in mysql console I used: SET PASSWORD FOR 'root'@'localhost' = PASSWORD('root'); – alim1990 Oct 19 '15 at 06:21
  • Are you able to access phpmyadmin using above user and password? – Altmish-E-Azam Oct 19 '15 at 06:22
  • Nope, I got this in http://localhost/phpmyadmin/ :#1045 - Access denied for user 'root'@'localhost' (using password: YES) phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server. – alim1990 Oct 19 '15 at 06:24
  • are you able to connect mysql from server console by root or any other admin user.... – Zafar Malik Oct 19 '15 at 06:27
  • Try this: http://stackoverflow.com/a/21983211/3283363 – Indrasinh Bihola Oct 19 '15 at 06:28
  • no the console close with a beep sound when i enter the password. @ZafarMalik – alim1990 Oct 19 '15 at 06:31
  • I tried it but nothing happens @IndrasinhBihola – alim1990 Oct 19 '15 at 06:32
  • Did you set this too `$cfg['Servers'][$i]['AllowNoPassword'] = true;`?? Restart mysql server after changes. – Indrasinh Bihola Oct 19 '15 at 06:48
  • so first of all you need to unlock your root password, you can by edit your my.cnf or my.ini after adding "skip-grant-tables" also can add "skip-networking" to prevent your server and restart mysql service and change root password and again remove these lines and restart mysql service. – Zafar Malik Oct 19 '15 at 07:08
  • @ZafarMalik can you explain more please i didnt understand you – alim1990 Oct 19 '15 at 07:39
  • as you can't connect your mysql server now so what can we do now...so first we need to break root password so that we can enter in mysql db then we can see your problem. so I ask you to do these steps to get root password back. – Zafar Malik Oct 19 '15 at 08:54
  • @ZafarMalik okay but how ? Give steps like 1...2...3... – alim1990 Oct 19 '15 at 11:04

2 Answers2

1

Please follow below steps:

Go to mysql server console and follow below steps:

Step1: open your config file and add below lines in [mysqld] section and save file.

skip-grant-tables
skip-networking

Step2: Restart your mysql service, you can use below command if using linux.

service mysqld restart 

Step3: Now connect mysql by below command-

mysql -uroot

Step4: Above command will connect you with mysql and will show mysql prompt like below-

mysql>

Step5: Now change root password as per below-

mysql> update mysql.user set password = password('root123') where user='root';
OR 
mysql> update mysql.user set password = password('root123') where user='root' and host = 'localhost';

mysql> flush privileges;

mysql> exit;

Step6: Now remove newly added lines from config file and restart mysql service again as per step2.

Finally now you can connect your web or phpmyadmin with root user.

Zafar Malik
  • 6,734
  • 2
  • 19
  • 30
  • I did exactly what you asked me to do in the 6 steps. But still got the error when I am using phpmyadmin: MySQL said: Documentation #1045 - Access denied for user 'root'@'localhost' (using password: YES) phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server. – alim1990 Oct 19 '15 at 11:51
  • now r u able to connect mysql from mysql server consol – Zafar Malik Oct 19 '15 at 12:40
  • no, but i uninstalled everything and reinstall and now it works. – alim1990 Oct 19 '15 at 12:59
  • Depending on your phpMyAdmin config, it uses a password hard coded in the phpmyadmin `config.inc.php` file. When you change the root password in MYSQL, you then have to amend the password that phpMyAdmin will try and use. PS There are better configs for phpMyAdmin that will make phpMyAdmin throw a login page so you can enter the `username` and `password` manually – RiggsFolly Oct 20 '15 at 11:15
0

Maybe root from localhost has not the required grant to access the DB.

Try to run the following on a mysql console:

GRANT ALL ON <yourdb>.* TO 'root'@'localhost';
FLUSH PRIVILEGES;
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient [reputation](http://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](http://stackoverflow.com/help/privileges/comment). – Sinister Beard Oct 19 '15 at 08:15
  • And what I just did wrong ? Just answer my post question and stop criticizing the way I make comment @BFDatabaseAdmin – alim1990 Oct 19 '15 at 08:21
  • @droidnation - Firstly, that's a standard reply that's generated by the review cue because this answer was flagged as potentially low quality. Secondly, it's not even directed at you, it's directed at the answerer, as this isn't a full answer. Thirdly, manners, please. – Sinister Beard Oct 19 '15 at 09:36
  • 1
    @BFDatabaseAdmin I could not comment on the original post. I posted the reply because I was quite sure that was the problem. – Luca Truffarelli Oct 19 '15 at 10:21
  • @LucaTruffarelli the problem is that mysql console make a beep sound and shut down immediately when i put the password – alim1990 Oct 19 '15 at 11:03