Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

How do I create a new user and password in wordpress using phpmyadmin and the site's mysql database dump?

Posted on 2014-09-16
Last Modified: 2014-09-21
Hi all,

A friend of mine has just passed a couple of sites he hosted on a shared server.
He had a spat with the owner who is also a programmer and this resulted in them falling out.
It so happens that he managed to recover all his site's wordpress files from the ftp and also the
database mysql file from the phpmyadmin interface. Sadly the sites have now been cancelled from the original server.
I have copied the files to my server, uploaded the db to a new one on my phpmyadmin.
However since the site was maintained and updated by this third party, after their fight
he never gave my friend his admin login and password.

Is there a way by using let's say phpmyadmin or even the linux ssh console of the server
(I have a private VPS and I can access the server using putty) to create a new user in the wordpress database
and assign a new password to him, so that I might login to the website and make the needed updates?

thanks in advance
Question by:badwolfff
  • 3
  • 2
  • 2
  • +1
LVL 38

Expert Comment

by:Tom Beck
ID: 40327098
Look in the wp_users table using PhpMyAdmin. There, you can get the admin's user name and email address. Attempt to log in to the Wordpress site, type in the admin's user name and click "Lost your password?" A reset link will be sent the the email address. If necessary, you can change the email address to one you have access to before you begin.
LVL 70

Expert Comment

by:Jason C. Levine
ID: 40327184
Exactly.  Just change the email address of the first user in the wp-users table (typically the admin user) to something you control and do a normal password reset from there.  

There's other ways to do it, though.  Here's a fun one:

function add_admin_acct(){
	$login = 'myacct1';
	$passw = 'mypass1';
	$email = 'myacct1@mydomain.com';

	if ( !username_exists( $login )  && !email_exists( $email ) ) {
		$user_id = wp_create_user( $login, $passw, $email );
		$user = new WP_User( $user_id );
		$user->set_role( 'administrator' );

Open in new window

Ref: http://stephanis.info/2011/08/11/create-new-admin-account-in-wordpress-via-ftp/

Nice, huh?  A little code injection and you're an admin.

Author Comment

ID: 40328269

there is something wrong with both your approaches in that these sites have an smtp issue too.
They were on another server before and the smtp configuration there was related to an email address which expired with the old domain. So when I try to send myself and email I get nothing.

Does anyone know a method that might allow me to use the linux SSH console (putty) to create a new user or find an existing user's name and change his password, using the mysql server prompt?

thanks in advance
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

LVL 38

Expert Comment

by:Tom Beck
ID: 40328463
Can't speak to the SSH console method.

Do you have access to another working installation of Wordpress and PhpMyAdmin? Create a new user name and password there. Go to PhpMyAdmin and copy the hash value of the password. Open the broken WP installation in PhpMyAdmin and paste the password hash into the entry for the admin account.

I don't recall ever entering specific smtp configuration into any WP installation unless I was using an email enhancer plugin. My understanding is that WP just opens an smtp connection on the host server without asking questions. Obviously you cannot relay through the old server now that you're on a different server but why would WP be attempting to do that? Is there an email plugin installed? Disable it and see if you get an email.

Another possible option is to open the functions.php file for the theme and write a function to over ride the smtp configuration as described here.
LVL 70

Expert Comment

by:Jason C. Levine
ID: 40328767
there is something wrong with both your approaches in that these sites have an smtp issue too.

Technically, there's nothing wrong with OUR approaches.  The mail issue is just a separate thing :)

So when I try to send myself and email I get nothing.

I would think your easiest course of action is to disable the SMTP stuff if it really is an SMTP issue but other things may be at work here. Some ISPs do not allow mail() to send messages unless the sending address matches the site domain (kind of a redneck open relay protection) and your server may have other issues with deliverability of messages.  In any event, I would add an SMTP plugin and also sign up for a free Mandrill account and use that server to send all WordPress email.  It should bypass the issues you are currently describing.

an existing user's name and change his password, using the mysql server prompt?

Not sure this would work because WordPress runs the passwords through a hashing function and stores that.  It's trivial to change the password in the database but without the hash, you still couldn't login.

My understanding is that WP just opens an smtp connection on the host server without asking questions.

Sort of.  In its default state, WordPress just opens up a mail() instance and pumps mail out that way.  You can force it to use an SMTP connection instead, which I strongly recommend people do.

Author Comment

ID: 40328884
ok boys thanks for the input
when I get to office tomorrow I will try the lot :)
when I said there is something wrong, I did not mean to offend, as what I was intending to say was
that for some reason these approaches are not producing the result for me :)
thanks for the answers
LVL 70

Expert Comment

by:Jason C. Levine
ID: 40329041
I did not mean to offend

You didn't, hence the emoticon. I did want to make it clear that the solutions are technically valid so a future user can try it and the email thing is a a different, albeit severe, issue.

Accepted Solution

Sam Cohen earned 500 total points
ID: 40333981
This is how you would do it in phpmyadmin:

Edit the wp_users table. Find any username. Change it's current password hash (example: $3tyh~24eXrt...........) to:


then click the Save button (or Go button).

Then login into Wordpress and and use "admin", as the password. Once logged in simply change the password to whatever you want.

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The purpose of this video is to demonstrate how to exclude a particular blog category from the main blog page. This is can be used when a category already has its own tab, or you simply want certain types of posts not to show up on the main blog. …
The viewer will learn how to dynamically set the form action using jQuery.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question