2

I'm trying to connect to an application. There was a power failure that corrupted the hard drive, and after taking a backup from it externally, I've managed to get the application back up. Looking at the files it seems fine, the database is there too. But mysql won't connect.

I get

 Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'myuser'@'localhost' (using password: YES) in C:\wamp\www\testmysql.php on line 2

where line 2 is simply:

$link = mysql_connect('localhost','myuser','mypassword'); 

I can still access PHPMYADMIN fine, and run queries, and browse tables. But I got this when trying to browse the table action_log:

enter image description here

The error says:

SQL query:
SHOW FULL FIELDS FROM `action_log`:

MySQL said:
#29 - File '.\mypath\action_log.MYD' not found (Errcode: 2)

It's a Windows machine. Where do I find that file? And do I need to do this? Howto: MySQL InnoDB corruption auto-repair after power failure?

Edit

I should add that when I run this, it works:

$link = mysql_connect('localhost','admin',''); 

Where/how can I restore the other users? Whether by files or via DB?

Community
  • 1
  • 1
user961627
  • 11,059
  • 35
  • 119
  • 202

1 Answers1

1

Maybe xampp is returned to defauld, and your username and password for phpmyadmin is root... Try to connect whit this: $link = mysql_connect('localhost','root',''); username is root and no password

Aleksandar
  • 574
  • 1
  • 9
  • 27
  • Yes I tried this and edited the question a few moments ago to add it - that line is working. So how do I get my old users back? – user961627 Feb 09 '13 at 12:16
  • You must go to phpmyadmin. Go to [phpmyadmin](http://localhost/phpmyadmin/server_privileges.php) and add new user account, if this address is not working, connect to phpmyadmin and find in settings or users, you have option `Add user` – Aleksandar Feb 09 '13 at 12:22
  • Did you find `Add user` in your phpmyadmin? If you cant find, i will help you. – Aleksandar Feb 09 '13 at 12:40
  • No I can't find it. I tried using the MySQL command line interface to create a user and grant all privileges - I think I wasn't doing that right but anyway I added a user then in the mysql database via phpMyAdmin and granted all rights to this user. When I ran the connection string up there, it worked! But mysql_select_db() fails. So how do I connect a user to a DB? – user961627 Feb 09 '13 at 13:03
  • maybe you not included all db-s for that user. In option `Database for user` you shuld click on `None`. – Aleksandar Feb 09 '13 at 13:08
  • Thanks a lot! I got it worked out anyway, using this: http://stackoverflow.com/questions/1720244/create-new-user-in-mysql-and-give-it-full-access-to-one-database – user961627 Feb 09 '13 at 13:30