wp_user not exist in phpmyadmin after importing to mysql

I did transfer my wordpress on localhost to server by uploading my wordpress files and importing mysql

but after importing mysql I can’t find wp_user in phpmyadmin database and I can’t login to my wordpress panel from wp-admin

Read More

what I have to do now?

Related posts

2 comments

  1. what I have to do now?

    Well it depends:

    If you still have the original database stored locally, check if the wp_users table exists in there. If yes, you probably haven’t exported this table. Just export it (by selecting the table, and then on export it only exports a single table) and import it on your server.

    If you don’t have the original database anymore, you can simply create one by executing the following SQL commands:

    CREATE TABLE IF NOT EXISTS `wp_users` (
    `ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `user_login` varchar(60) NOT NULL DEFAULT '',
    `user_pass` varchar(64) NOT NULL DEFAULT '',
    `user_nicename` varchar(50) NOT NULL DEFAULT '',
    `user_email` varchar(100) NOT NULL DEFAULT '',
    `user_url` varchar(100) NOT NULL DEFAULT '',
    `user_registered` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
    `user_activation_key` varchar(60) NOT NULL DEFAULT '',
    `user_status` int(11) NOT NULL DEFAULT '0',
    `display_name` varchar(250) NOT NULL DEFAULT ''
    );
    

    And adding some indices for quicker processing

    ALTER TABLE `wp_users`
      ADD PRIMARY KEY (`ID`),
      ADD KEY `user_login_key` (`user_login`),
      ADD KEY `user_nicename` (`user_nicename`);
    

    Then you’re able to insert your admin user by executing

    INSERT INTO `databasename`.`wp_users` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES ('4', 'demo', MD5('demo'), 'Your Name', 'test@yourdomain.com', 'http://www.test.com/', '2011-06-07 00:00:00', '', '0', 'Your Name');
    
    
    INSERT INTO `databasename`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '4', 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
    
    
    INSERT INTO `databasename`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '4', 'wp_user_level', '10');
    

    (Queries copied from here.) Don’t forget to use your values.

    * Note: that the first query uses MD5. MD5 is definitely not the best way of storing passwords. (See here for example). According to the WP Codex WordPress currently still supports logging in if a MD5 Hash is stored:

    Note that even if the passwords are salted, meaning they look like $P$BLDJMdyBwegaCLE0GeDiGtC/mqXLzB0, you can still replace the password with an MD5 hash, and WordPress will let you log in.

    So if you’re doing this, please update your password afterwards using the WordPress interface to ensure your password isn’t stored as a MD5 hash.

    And in the end you should check that your wp-config.php contains the right database host and credentials.

Comments are closed.