1

I'm trying to reset my Joomla admin password by executing the following code in MySQL:

INSERT INTO `jos_users` (`id`,`name`, `username`, `password`, `params`)
VALUES (LAST_INSERT_ID(),'Administrator2', 'admin2',
'd2064d358136996bd22421584a7cb33e:trd7TvKHx6dMeoMmBVxYmg0vuXEA4199', '');

INSERT INTO `jos_user_usergroup_map` (`user_id`,`group_id`)
VALUES (LAST_INSERT_ID(),'8');

When I attempt to execute it, I get the following error:

Failed to execute SQL : SQL INSERT INTO `jos_users` (`id`,`name`, `username`, `password`, `params`) VALUES (LAST_INSERT_ID(),'Administrator2', 'admin2', 
'd2064d358136996bd22421584a7cb33e:trd7TvKHx6dMeoMmBVxYmg0vuXEA4199', ''); INSERT INTO
`jos_user_usergroup_map` (`user_id`,`group_id`) VALUES (LAST_INSERT_ID(),'8'); failed : 
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INSERT INTO `jos_user_usergroup_map` (`user_id`,`group_id`) VALUES (LAST_INSERT_' at line 1

Could someone tell me where my Syntax might be wrong? I'm using MySQL version 5.0.95.

Bart De Vos
  • 17,761
  • 6
  • 62
  • 81
Arthur
  • 279
  • 1
  • 3
  • 11

1 Answers1

2

Use back ticks (`) around column name password (password is a reserved work in MySQL) if you are not using. Don't use LAST_INSERT_ID() in the first query as you have not added any record to this table yet. The queries will be

INSERT INTO jos_users (`name`, `username`, `password`, `params`) 
VALUES ('Administrator2', 'admin2', 'd2064d358136996bd22421584a7cb33e:trd7TvKHx6dMeoMmBVxYmg0vuXEA4199', '');

INSERT INTO `jos_user_usergroup_map` (`user_id`,`group_id`)
VALUES (LAST_INSERT_ID(),'8');

Make sure you run these queries in the same session.

Wasif
  • 330
  • 1
  • 9