How to add an Admin account in OpenCart 1.5 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.

  1. First, log into your cPanel account.
  2. From the main cPanel area, locate and find the Databases category, then click on the phpMyAdmin tool icon.
  3. 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.
  4. Once the database information loads into the right hand panel, look to the top tab menu, locate the SQL tab and click on it.
  5. 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.

  6. Click on the Go button to activate the query and add the record.
  7. 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.
Share this Article