0

I have installed php and mysql. But cannot set the root password.

This is what I've done so far:

sudo apt-get install mysql-server
sudo apt-get install mysql-client

After that:

mysql -u root -p mypass

and when it asks me for my pass, I type mypass again.

After that it says:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

What can I do? I thought about modifying the configuration files by hand, but I have no idea where they are.

3
  • What password did you set during installation of the server? Use it instead of mypass. The command to set or change a password is mysqladmin password ..., whereas mysql -u root -p pass simply logs into mysql as root.
    – muru
    Jul 26, 2014 at 2:12
  • Oh I see, so I should first do mysqladmin password mypassword?
    – Rosamunda
    Jul 26, 2014 at 2:13
  • Yes, something like: mysqladmin -u root -p current_password password new_password
    – muru
    Jul 26, 2014 at 2:14

1 Answer 1

1

Found the answer and maybe it's useful to somebody else.

The thing is that, even after uninstalling the mysql server in order to install it again and try it over, the system didn't allow me to create a password.

So I did uninstall it using sudo apt-get remove mysql-server and after that sudo apt-get autoremove, but that wasn't enough. The error was still there.

What it did solve the issue was:

sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get update && sudo apt-get upgrade

After that I started all over, and it was a clean install:

sudo apt-get install mysql-server

And the system asked me to set a password before the installation was over.

1
  • If that was the case, you could try sudo dpkg-reconfigure mysql-server. That should ask for a password unless you used debconf selections, which I am sure you didn't.
    – muru
    Jul 26, 2014 at 12:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .