Because you granted it access without password...
If a user has no password, logging in with one will always fail.
Set the password for user, only then you'll be able to use -p
In addition, you might want to remove the Any
user.
This will depend a bit on your table type. With MyISAM tables, you can generally just copy the folder and files and everything will work. With other table types, it sometimes doesn't work as well.
The first thing you can try is to completely replace your MySQL data directory with the one from the backup. I would move it out of the way (mv /var/lib/mysql /var/lib/mysql-orig
) so that you can easily restore it. Do this with the MySQL server not running and preferably on a testing server so you don't accidentally break something on your production machine.
Since you have the old hard drive data but can't get the drive to boot, it may be relatively painless to start MySQL from that drive (you can do this in a couple of ways; chroot to the old drive and try to start it there, copy the files to a server with a working MySQL instance, stop mysqld, edit the configuration file to point to the old mysql data directory, then restart MySQL, or finally just follow the steps above to completely replace the mysql data directory on the working instance with the one from the old server.
As D. Kasipovic points out, you should check the file permissions on the files you have restored, it could be as simple as a file permission problem.
You should make sure you're connecting as the root user or another user with administrative permissions; otherwise it's likely that a MySQL permissions will keep you from being able to see the databases. Depending what method ends up working for you, you may need to create any users that had permissions on that database.
Best Answer
You can do it with some simple commands:
When the file my.cnf is opened you can read it's contents, and it should contain your username and password for the current installation.
Hope this helps! ;)