346: How to add an Admin account in OpenCart via MySQL
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 VALUESFeel free to change the 'firstname', 'lastname', and 'firstname.lastname@example.org' 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.
(9999,1, 'admin123', '21232f297a57a5a743894a0e4a801fc3', '',
'firstname', 'lastname', 'email@example.com', '',
- 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.
‹Section 3: 347: Enabling email alerts within OpenCart 1.5
›Section 5: 333: Adding a manufacturer to the banner in OpenCart
We value your feedback!
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
new! - Enter your name and email address above and we will post your feedback in the comments on this page!
2014-09-22 6:14 pm
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".
2014-09-22 6:51 pm
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.
2014-09-22 7:12 pm
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 v18.104.22.168 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.
2014-09-22 7:26 pm
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.