如何通过MySQL数据库添加WordPress新用户插图

The design goal of WordPress gives you flexibility, but the most effective way to perform tasks is through the dashboard. You can get almost all aspects of the installation here, usually through an intuitive graphical user interface (GUI). Sometimes, however, using a dashboard may not be the best way. For example, you might want to add new users through the MySQL database instead of using a dedicated screen in WordPress.

although we don’t recommend that you look around the MySQL database for daily tasks, setting up users through the database seems like a simple and crude way when you don’t have access to the dashboard. This is an extreme solution to a unique problem, but if you need it, it will be your only solution.

in this article, we will show you how to add new users through the MySQL database. Before that, we should see why you did it.

adds a new user

through the MySQL database We acknowledge that you may be reading this article because you cannot access the dashboard of the WordPress website and already know why. In most cases, you will not have physical access to any other part of the WordPress, so you must “walk a long way” to enter your site.

as to why this happens, the first reason is user participation. This can cover some innocent and malicious use cases:

  • you may forget and / or lose your user credentials, and there are no other administrator users to rely on.
  • may make you more comfortable in the interface of the MySQL database (although this may be rare).
  • you are the victim of a malicious attack that harmed your website.
  • you may also be struggling with a disgruntled former administrator user who exercises the ability to lock you out of your site.

, of course, many of the reasons are dramatic and extreme. Regardless of the reason why you cannot access it, you can take advantage of the accessibility of the MySQL database to create a new WordPress user. How

accesses your MySQL database

you need to access the database itself before setting up new users. If you are brave enough, you can do this from the command line, but there is a more direct way.

you can access your database through administrative tools such as phpMyAdmin or Adminer. Depending on your landlord, you will find one of them. Few hosts do not provide one or even an alternative database management solution.

phpMyAdmin has long been a typical standard:

如何通过MySQL数据库添加WordPress新用户插图1

you will have a tree directory on the left, a complete database. Expand these to display the Table list. They are like worksheets in Excel or spreadsheet applications and hold individual elements of the data. You can also nest tables, which is a common way to build data structures for WordPress.

each table contains a specific “slice” of data, such as comments, content, and users. In fact, the database contains almost everything related to your WordPress site. Therefore, it is the basic element of your site and is also very important.

We’ll see where to find your list of WordPress users later. Now, let’s take a detour and talk about the hacker attacks on your website.

what if you suspect that your website has been hacked?

before we continue, it is very important to talk about hacked websites. If you suspect that your website has been hacked, you should act quickly. This is the topic we discuss elsewhere in the blog, but in short, you need to eliminate the threat before you do anything else.

if you encounter problems visiting a hacked website, our advice is to contact a professional company, such as WP Tech Support, Sucuri, Wordfence or MalCare. They will be able to help you control the situation, which will give you the opportunity to support future sites. How

adds new WordPress users through the MySQL database

remember to make a full backup of your site and database before opening any database management tool of your choice. If the worst happens and you need to restore your website, these files will be the most valuable to you. Once

is ready, you need to perform the following steps:

  • uses your favorite tool to access your MySQL database.
  • opens thewp_userstable.
  • inserts the user into the table.
  • adds functionality for new users.

for a complex task, each step is much simpler than you might expect. As a first step, you need to open the MySQL database.

1. First of all, you should look at the tools provided by the host to log in to your MySQL database

using dedicated administrative tools. Although there are many management solutions, most hosts use phpMyAdmin or Adminer. The process is the same, and although we will use Adminer in this article, we will also notice when phpMyAdmin’s instructions differ.

Please note that you need your database credentials to log in, not your site or hosting details. These are usually located in your host control panel, and if you have difficulty finding details, we recommend that you contact your host.

You may also have to look for links to your database access, because hosts often have custom dashboards that are inconsistent between companies. This is more common as managed service providers move away from cPanel. Even for this managed dashboard, though, the link to phpMyAdmin stands out:

如何通过MySQL数据库添加WordPress新用户插图2

, regardless of your host and database management tools, the login process is similar to almost all other “locked” systems. Just enter your user name and password, then click and wait for the database information to load.

2. After locating and accessing thewp_usersform

, you need to find the wp_users table, because this is where you work. The process for most interfaces is the same: look at the table on the left, namedwp_users. The problem here, however, is that it may have a different name, depending on whether you use a custom table prefix:

如何通过MySQL数据库添加WordPress新用户插图3

. Anyway, the table should have the name “users”. If you click it in the left column, it will open in the main area of the screen:

如何通过MySQL数据库添加WordPress新用户插图4

, for phpMyAdmin, should open a screen showing a list of users. For Adminer, it shows the table structure, which helps you understand what information you need to enter and how to enter it. To see the list of current users, select the Select data link:

如何通过MySQL数据库添加WordPress新用户插图5

from here, you can start adding new users.

3. Insert new users into the table

Adminer and phpMyAdmin both have links on thewp_userstable screen for entering new data. For phpMyAdmin, you will choose the Insert link at the top, while in Adminer it is New item:

如何通过MySQL数据库添加WordPress新用户插图6

, but because you are dealing with the same type of database, the fields you need to enter will be the same:

  • user_login: you can select a login here and enter it into the relevant WordPress field.
  • user_pass: you should enter your password here, but be sure to select MD5 from the drop-down menu in the field. This helps to “hash” your password and protect it from further malicious attacks.
  • user_nicename: currently, use the same name as user_login, but remove all special characters and capitals.
  • user_email: this can be an email address that you can access.
  • user_registered: this will be the timestamp of your registration, which should be the current data and time. You can now choose from the drop-down menu here to help you.
  • user_status: you can set this value to zero. After

completes these fields, click Save or Go, and the list updates to show the new user. Although, this is the end of the work. You must ensure that the new user has the correct permissions.

4. Add specific competencies for newly created users

before you can log in as a new user, you need to apply some features to grant administrative rights to the user. First, write down the user ID number in thewp_userstable:

如何通过MySQL数据库添加WordPress新用户插图7

. Next,wp_usermetafinds the table from the list on the left:

如何通过MySQL数据库添加WordPress新用户插图8

, which will show you many details about each user, but not for your new additions. Much like the last step, your task is to add new rows to the table. Here’s how to fill in the field:

  • user_id: this should be the same ID you just wrote down.
  • meta_key:wp_capabilities
  • meta_value:a:1:{s:13:"administrator";b:1;}

Click again to continue, and you should be able to log in to your site using the front-end WordPress login form.

summary

this is a rare situation, which means that you need to open the MySQL database to process your content. In most cases, the WordPress dashboard is an excellent platform for dealing with the elements of your site. However, if you cannot access your website for innocent or malicious reasons, logging in to your database will cause you to perform almost the same number of tasks.

in this article, we showed you how to add new users through the MySQL database. The hardest part of the task is to add user functionality, but the required metadata is not difficult to write. When you are finished, you can log in to your site through the GUI interface commonly used on the network.

Disclaimer: All articles on this website, unless otherwise specified or marked, are original and published on this website. Any individual or organization is prohibited from copying, stealing, collecting, or publishing the content of this site to any website, book, or other media platform without the consent of this site. If the content on this website infringes on the legitimate rights and interests of the original author, you can contact us for assistance.