Errors in programs and databases can occur quickly and mysteriously. If something disasterous happens such as your admin account being deleted, it will seem imposible for your to fix as you need to get into the administrative area to troubleshoot or promote another user account to the Administrative role. In cases like this, you need to create an emergency admin account. This cannot be done through normal means and will need to be done with direct database interaction. Below is a guide on how to insert an admin account into your OpenCart 1.5 database.
- First, log into your cPanel account.
- From the main cPanel area, locate and find the Databases category, then click on the phpMyAdmin tool icon.
- Look to the left hand sidebar and click on the database name for your OpenCart installation. If you are unsure about the name, you can discover it by following these instructions.
- Once the database information loads into the right hand panel, look to the top tab menu, locate the SQL tab and click on it.
- Here is the SQL query editor. From here, we will enter some code that will create a new admin account for you. Below is the code to create a new admin account named admin123 and with the password admin.INSERT INTO oc_user VALUES
(9999,1, ‘admin123’, ‘21232f297a57a5a743894a0e4a801fc3’, ”,
‘firstname’, ‘lastname’, ’[email protected]’, ”,
‘0.0.0.0’,1,CURDATE());Feel free to change the ‘firstname‘, ‘lastname‘, and ‘[email protected]‘ data to anything you like as they should be obvious and are not crucial to getting you into the application. Do not change any of the other fields, however.
- Click on the Go button to activate the query and add the record.
- You will get a success message indicating the row was added. You can now test the user by logging into your OpenCart administrative area with the username admin123 and the password admin.
I’ve tried adding a new OpenCart user in v 2.0.1.1 in the SQL doing the above, but I get a “Unexpected Token” Red cross error – any ideas?
Sam, the instructions in this article only apply to OpenCart 1.5. In version 2.0 OpenCart had major updates and changes, and this makes the instructions above not relevant for other versions of OpenCart. You may wish to ask about this in the OpenCart forums at https://forum.opencart.com/
Hello,
Please I added the code and got this feedback, #1136 – Column count doesn’t match value count at row 1
I am using opencart 2.0.2.0 and upgraded from 1.5.6.
We have lost permissions to make any changes at the back office. Kindly help us.
Thanks.
Dornu
Where are you seeing the error you mentioned? When you say you lost permissions do you mean you can’t log in? Or are you seeing a different error to indicate you don’t have the necessary permissions?
Open cart 2 has extra field “code” so use:
INSERT INTO oc_user VALUES
(9999,1, ‘username’, ‘21232f297a57a5a743894a0e4a801fc3’, ”,
‘firstname’, ‘lastname’, ’emailaddress’, ‘ ‘,’ ‘,
‘0.0.0.0’,1,CURDATE());
Hello Abigail,
Thank you for sharing this information.
If you have any further questions, feel free to post them below.
Thank you,
John-Paul
Thanks for the speedy response Scott, unfortuantely I have tried to reset my password. It says it works but it still refuses to let me log in. I have checked the database through phpMyAdmin and all seems ok, and yet I am still locked out. Is there anything else a person can try?
Hello John,
Sorry for the problems with the login. If you are unable to get your password working through the automated options, then you will need to contact live support. They can change it for you very quickly once your account information has been verified. You can reach live support through phone/email/chat .
Kindest regards,
Arnel C.
I followed the instructions, recieved the all ok. Checked the DB and the user was there but the login and pass did not work. Anything else I can try?
Hello John,
As long as you have access to the email address you inserted, you can just follow the instructions for the forgotten password link to have it change that. Then you should be able to get in.
Kindest Regards,
Scott M
It was worth a shot. Thanks guys.
Arnel, thanks for the quick reply. I’m not a InMotion customer, but just looking for someone that can help.
It’s an Aceshop v1.4.6 installation (Opencart v1.5.1.3 within Joomla). I have a bunch of vqmod additions but didn’t think they would matter for basic top admin access and the template is a standard opencart release.
I’m not sure what the cause was as I hadn’t made any changes to permissions, but I found myself locked out. I reset the password via phpmyadmin, but am only able to access the dashboard and denied access to everything else. I’m not super familiar with opencart sql so am not quite sure what I’m doing when it comes to editing permissions.
As this is not just a standard OpenCart installation, some things may not be the same as a typical OpenCart installation. Your best solution may be to contact the developer of Aceshop for more information on performing the changes that you need to make.
I added the prefix so to query the right table, but I still get an error saying “#1136 – Column count doesn’t match value count at row 1”.
Any ideas?
Hello Dave,
Sorry for the problem. Can you provide us any account details (if you’re a customer with InMotion), or can you provide any information on the installation – version of OpenCart, plugins, or themes. We need more information in order to investigate the issue.
Regards,
Arnel C.