WordPress is written using PHP as its scripting language and MySQL as its database management system. In order to use WordPress, you don’t really need to learn either of them.
WordPress是使用PHP作为其脚本语言以及使用MySQL作为其数据库管理系统来编写的。 为了使用WordPress ,您实际上不需要学习它们中的任何一个。
However, a very basic understanding of the two could help you troubleshoot problems as well as increase your understanding of how WordPress works (behind the scenes).
但是,对这两者的非常基本的了解可以帮助您解决问题以及增加对WordPress工作原理的了解(在幕后) 。
In this article, we will explain how WordPress uses the database including an intro to default WordPress database tables.
在本文中,我们将说明WordPress如何使用数据库,包括默认WordPress数据库表的简介。
We will also show you how to manage a WordPress database using phpMyAdmin which will include creating database backups, optimizing the WordPress database, and more.
我们还将向您展示如何使用phpMyAdmin管理WordPress数据库,包括创建数据库备份,优化WordPress数据库等等。

This is a comprehensive guide on WordPress database management, so we have added a table of contents for easier navigation:
这是有关WordPress数据库管理的综合指南,因此我们添加了目录,以简化导航:
- What is a database and how WordPress uses it?什么是数据库以及WordPress如何使用它?
- What is phpMyAdmin?什么是phpMyAdmin?
- How to access phpMyAdmin如何访问phpMyAdmin
- Understanding WordPress database tables了解WordPress数据库表
- Managing WordPress database via phpMyAdmin通过phpMyAdmin管理WordPress数据库
- Creating a WordPress database backup using phpMyAdmin使用phpMyAdmin创建WordPress数据库备份
- Creating a WordPress backup using a plugin使用插件创建WordPress备份
- Importing WordPress database using phpMyAdmin使用phpMyAdmin导入WordPress数据库
- Optimizing your WordPress database using phpMyAdmin使用phpMyAdmin优化WordPress数据库
- Fixing WordPress issues using phpMyAdmin使用phpMyAdmin修复WordPress问题
- Reset WordPress password using phpMyAdmin使用phpMyAdmin重置WordPress密码
- Adding a new WordPress admin user via phpMyAdmin通过phpMyAdmin添加新的WordPress管理员用户
- Changing a WordPress username using phpMyAdmin使用phpMyAdmin更改WordPress用户名
- Other useful phpMyAdmin tricks其他有用的phpMyAdmin技巧
- Securing your WordPress database保护您的WordPress数据库
什么是数据库以及WordPress如何使用它? (What is a Database and How WordPress Uses it?)
A database is a system of storing and fetching data in an organized way. Database allows software to manage data in a programmable way.
数据库是一种以组织方式存储和获取数据的系统。 数据库允许软件以可编程方式管理数据。
For example: WordPress uses PHP (programming language) to store and retrieve data from the database.
例如:WordPress使用PHP(编程语言)存储和检索数据库中的数据。
The information stored in a WordPress database includes posts, pages, comments, categories, tags, custom fields, users, and other WordPress settings. We will elaborate on this later in the tutorial when we cover all WordPress database tables.
WordPress数据库中存储的信息包括帖子,页面,评论,类别,标签,自定义字段,用户和其他WordPress设置。 当我们涵盖所有WordPress数据库表时,我们将在本教程的后面部分对此进行详细说明。
When you first install WordPress, it asks you to provide a database name, host, username, and password. This information is stored in the configuration file called wp-config.php.
首次安装WordPress时 ,它会要求您提供数据库名称,主机,用户名和密码。 此信息存储在名为wp-config.php的配置文件中。

During the installation, WordPress uses the information you provide about the database to create tables and store default installation data inside those tables.
在安装过程中,WordPress将使用您提供的有关数据库的信息来创建表并将默认安装数据存储在这些表中。
After the installation, WordPress runs queries to this database to dynamically generate HTML pages for your website or blog.
安装后,WordPress对该数据库运行查询,以动态生成网站或博客的 HTML页面。
This is what makes WordPress extremely powerful because you don’t have to create a new .html file for each page that you want to create. WordPress handles everything dynamically.
这就是WordPress极其强大的原因,因为您不必为要创建的每个页面创建一个新的.html文件。 WordPress可动态处理所有内容。
Where is my WordPress database stored?
我的WordPress数据库存储在哪里?
WordPress uses MySQL as its database management system, which is a software installed on your WordPress hosting server. Your WordPress database is also stored on the same server.
WordPress使用MySQL作为其数据库管理系统,该系统是安装在WordPress托管服务器上的软件。 您的WordPress数据库也存储在同一服务器上。
This location however is not accessible on most shared hosting environments. However, if you are on a VPS hosting plan or a dedicated server, then you can use command line tools to locate the database.
但是,在大多数共享主机环境中无法访问此位置。 但是,如果您使用的是VPS托管计划或专用服务器,则可以使用命令行工具来查找数据库。
Most often it is located at the following path:
通常,它位于以下路径:
/var/lib/mysql/your_database_name
/ var / lib / mysql /您的数据库名称
However, this could differ from one hosting provider to another.
但是,这可能会因托管服务提供商而异。
It is important to keep in mind that you don’t really need to access the database file itself. You can use other tools like phpMyAdmin to manage your database.
重要的是要记住,您实际上并不需要访问数据库文件本身。 您可以使用phpMyAdmin等其他工具来管理数据库。
什么是phpMyAdmin? (What is phpMyAdmin?)
PhpMyAdmin is a web-based software that allows you to manage MySQL databases using your web browser. It offers an easy to use interface that allows you to run MySQL commands and database operations.
PhpMyAdmin是一个基于Web的软件,可让您使用Web浏览器管理MySQL数据库。 它提供了易于使用的界面,允许您运行MySQL命令和数据库操作。
You can also use it to browse and edit database tables, rows, and fields. It also allows you to import, export, or delete all data inside a database.
您还可以使用它来浏览和编辑数据库表,行和字段。 它还允许您导入,导出或删除数据库中的所有数据。
如何访问PhpMyAdmin? (How to Access PhpMyAdmin?)
PhpMyAdmin comes pre-installed with all top WordPress hosting companies. You can find it under the Databases section of your hosting account’s cPanel dashboard. Below is an example screenshot from Bluehost control panel:
所有顶级WordPress托管公司都预装了PhpMyAdmin。 您可以在托管帐户的cPanel信息中心的“数据库”部分下找到它。 以下是Bluehost控制面板的示例屏幕截图:

Depending on your hosting provider, your cPanel interface may look different than the above screenshot. You would still be able to find phpMyAdmin icon under the databases section.
根据您的托管服务提供商,您的cPanel界面可能与上述屏幕截图有所不同。 您仍然可以在“数据库”部分下找到phpMyAdmin图标。
Clicking on it will open the phpMyAdmin interface where you can select your WordPress database from the left column. After, that phpMyAdmin will display all tables in your WordPress database.
单击它将打开phpMyAdmin界面,您可以在其中从左栏中选择WordPress数据库。 之后,该phpMyAdmin将显示您的WordPress数据库中的所有表。

Let’s take a look at the WordPress database tables.
让我们看一下WordPress数据库表。
了解WordPress数据库表 (Understanding WordPress Database Tables)
Each WordPress installation has 12 default tables in the database. Each database table contains data for different sections, features, and functionality of WordPress.
每个WordPress安装程序在数据库中都有12个默认表。 每个数据库表都包含WordPress的不同部分,特征和功能的数据。
Looking at the structure of these tables, you can easily understand where different parts of your website are stored. Currently, a default WordPress installation creates the following tables:
查看这些表的结构,您可以轻松地了解网站不同部分的存储位置。 当前,默认的WordPress安装会创建以下表格:
Note: wp_
before each table name is the database prefix you choose during the installation. It can be different if you changed it at the time of installation.
注意:每个表名之前的wp_
是您在安装过程中选择的数据库前缀 。 如果在安装时进行了更改,则可能会有所不同。
wp_commentmeta : This table contains meta information about comments posted on a WordPress website. The table has four fields meta_id, comment_id, meta_key, and meta_value. Each meta_id is related to a comment_id. One example of comment meta information stored is the status of comment (approved, pending, trash, etc).
wp_commentmeta:该表包含有关在WordPress网站上发布的评论的元信息。 该表具有四个字段meta_id,comment_id,meta_key和meta_value。 每个meta_id与comment_id相关。 存储的评论元信息的一个示例是评论的状态(已批准,未决,垃圾等)。
wp_comments : As the name suggests this table contains your WordPress comments. It contains comment author name, url, email, comment, etc.
wp_comments:顾名思义,该表包含您的WordPress注释。 它包含评论作者姓名,URL,电子邮件,评论等。
wp_links : To manage blogrolls create by earlier versions of WordPress or the Link Manager plugin.
wp_links:要管理由早期版本的WordPress或Link Manager插件创建的博客卷。
wp_options : This table contains most of your WordPress site-wide settings such as: site url, admin email, default category, posts per page, time format, and much much more. The options table is also used by numerous WordPress plugins to store plugin settings.
wp_options:此表包含您的大多数WordPress网站范围设置,例如:网站url,管理电子邮件,默认类别,每页帖子数,时间格式等等。 众多WordPress插件还使用options表来存储插件设置。
wp_postmeta : This table contains meta information about your WordPress posts, pages, and custom post types. Example of post meta information would be which template to use to display a page, custom fields, etc. Some plugins would also use this table to store plugin data such as WordPress SEO information.
wp_postmeta:此表包含有关WordPress帖子,页面和自定义帖子类型的元信息。 发布元信息的示例是用于显示页面, 自定义字段等的模板。某些插件还将使用此表存储插件数据,例如WordPress SEO信息 。
wp_posts : The name says posts but actually this table contains all post types or should we say content types. This table contains all your posts, pages, revisions, and custom post types.
wp_posts:名称表示帖子,但实际上此表包含所有帖子类型,或者我们应该说内容类型。 该表包含您的所有帖子,页面,修订和自定义帖子类型 。
wp_termmeta : This table allows developers to store custom metadata for terms under their custom taxonomies. For example, WooCommerce uses it to store metadata for product attributes and categories.
wp_termmeta:此表允许开发人员在其自定义分类法下存储术语的自定义元数据。 例如, WooCommerce使用它来存储产品属性和类别的元数据。
wp_terms : WordPress has a powerful taxonomy system that allows you to organize your content. Individual taxonomy items are called terms, and they are stored in this table. For example, your WordPress categories and tags are taxonomies, and each category / tag inside them is a term.
wp_terms: WordPress具有功能强大的分类系统,可让您组织内容。 各个分类项目称为术语,它们存储在此表中。 例如,您的WordPress 类别和标签是分类法,其中的每个类别/标签都是一个术语。
wp_term_relationships : This table manages relationship of WordPress post types with terms in wp_terms table. For example this is the table that helps WordPress determine post X is in Y category.
wp_term_relationships:该表管理WordPress帖子类型与wp_terms表中的术语的关系。 例如,此表可帮助WordPress确定X属于Y类别。
wp_term_taxonomy : This table defines taxonomies for terms defined in wp_terms table. For example, if you have a term “WordPress Tutorials“, then this table contains the data that says it is associated with a taxonomy called category. In short, this table has the data that helps WordPress differentiate between which term is a category, which is a tag, etc.
wp_term_taxonomy:该表为wp_terms表中定义的术语定义分类法。 例如,如果您有一个术语“ WordPress Tutorials ”,则此表包含的数据表示该数据与名为category的分类法相关。 简而言之,此表中的数据可帮助WordPress区分哪个术语是类别,哪个标签等。
wp_usermeta : Contains meta information about registered users on your website.
wp_usermeta:包含有关您网站上注册用户的元信息。
wp_users : Contains user information like username, password, user email, etc.
wp_users:包含用户信息,例如用户名,密码,用户电子邮件等。
使用phpMyAdmin管理WordPress数据库 (Managing WordPress Database using phpMyAdmin)
Your WordPress database contains important WordPress settings, all your blog posts, pages, comments, and more. You need to be extremely careful when using phpMyAdmin, or you may end up accidentally deleting important data.
您的WordPress数据库包含重要的WordPress设置,您的所有博客文章,页面,评论等。 使用phpMyAdmin时需要格外小心,否则可能会意外删除重要数据。
As a precaution, you should always create a complete database backup. This would allow you to restore your database the way it was before.
作为预防措施,您应始终创建完整的数据库备份 。 这将使您能够以以前的方式还原数据库。
Let’s take a look at how to easily create a WordPress database backup.
让我们看一下如何轻松创建WordPress数据库备份。
使用phpMyAdmin创建WordPress数据库备份 (Creating a WordPress Database Backup using phpMyAdmin)
To create a backup of your WordPress database from phpMyAdmin, click on your WordPress Database. On the top menu, click on the Export tab.
要从phpMyAdmin创建WordPress数据库的备份,请单击WordPress数据库。 在顶部菜单上,单击“ 导出”选项卡。

In newer versions of phpMyAdmin, it will ask you for an export method. The quick method will export your database in a .sql file. In the custom method, it will provide you with more options and ability to download backup in compressed zip or gzip archive.
在较新版本的phpMyAdmin中,它将要求您提供导出方法。 快速方法将数据库导出为.sql文件。 在自定义方法中,它将为您提供更多选项,并能够以压缩的zip或gzip存档下载备份。
We recommend using the custom method and choosing zip as the compression method. The custom method also allows you to exclude tables from the database.
我们建议使用自定义方法,然后选择zip作为压缩方法。 自定义方法还允许您从数据库中排除表。
Let’s say if you used a plugin that created a database table, and you are no longer using that plugin, then you can choose to exclude that table from the backup if you want.
假设如果您使用了创建数据库表的插件,而不再使用该插件,那么可以根据需要选择从备份中排除该表。

Your exported database file can be imported back into a different or the same database using phpMyAdmin’s import tab.
您可以使用phpMyAdmin的导入选项卡将导出的数据库文件导入回另一个或相同的数据库。
使用插件创建WordPress备份 (Creating a WordPress Backup using a Plugin)
Keeping regular backups of your WordPress site is the best thing you can do for your WordPress security. While the WordPress database contains the majority of your site information, it still lacks several fairly important elements such as template files, images, uploads, etc.
维护WordPress网站的定期备份是您为WordPress安全所做的最好的事情。 虽然WordPress数据库包含您的大多数站点信息,但它仍然缺少一些相当重要的元素,例如模板文件,图像,上载等。
All your images are stored in the uploads folder in your /wp-content/ directory. Even though the database has the information which image is attached to a post, it is useless if the image folder doesn’t have those files.
您所有的图像都存储在/ wp-content /目录的uploads文件夹中。 即使数据库具有将哪个图像附加到帖子的信息,但如果图像文件夹中没有这些文件,则它是无用的。
Often beginners think that the database backup is all that they need. It is NOT true. You need to have a full site backup that includes your themes, plugins, and images.
通常,初学者认为数据库备份就是他们所需要的。 这不是真的。 您需要完整的站点备份,其中包括主题,插件和图像。
While most hosting companies claim they have daily backups, we recommend that you keep backups yourself just in case.
尽管大多数托管公司声称他们每天都有备份, 但我们建议您自己保留备份,以防万一 。
Note: If you are on a managed WordPress hosting solution like WPEngine, then they do create daily backups.
注意:如果您使用的是WPEngine之类的托管WordPress托管解决方案,则它们确实会创建每日备份。
For the majority of us who are not on WPEngine, you should use a WordPress backup plugin to set up automated WordPress backups on your site.
对于大多数未使用WPEngine的人 ,您应该使用WordPress备份插件在您的站点上设置自动WordPress备份。
通过phpMyAdmin导入WordPress数据库备份 (Importing a WordPress Database Backup via phpMyAdmin)
PhpMyAdmin also allows you to easily import your WordPress database. Simply launch phpMyAdmin and then select your WordPress database.
PhpMyAdmin还允许您轻松导入WordPress数据库。 只需启动phpMyAdmin,然后选择您的WordPress数据库。
Next, you need to click on the ‘Import’ link from the top menu.
接下来,您需要点击顶部菜单中的“导入”链接。

On the next screen, click on the Choose file button and then select your database backup file you downloaded earlier.
在下一个屏幕上,单击“选择文件”按钮,然后选择您先前下载的数据库备份文件。
PhpMyAdmin will now process your backup file upload and import it into your WordPress database. Once finished, you will see a success message.
现在,PhpMyAdmin将处理您的备份文件上传并将其导入到WordPress数据库中。 完成后,您将看到一条成功消息。

在phpMyAdmin中优化WordPress数据库 (Optimizing your WordPress Database in phpMyAdmin)
After using WordPress for a while, your database becomes fragmented. There are memory overheads which increase your overall database size and query execution time.
在使用WordPress一段时间后,您的数据库变得支离破碎。 内存开销会增加您的总体数据库大小和查询执行时间。
MySQL comes with a simple command that allows you to optimize your database. Simply go to phpMyAdmin and click on your WordPress database. This will show you a list of your WordPress tables.
MySQL附带了一个简单的命令,可让您优化数据库。 只需转到phpMyAdmin并单击您的WordPress数据库。 这将向您显示WordPress表的列表。
Click on the check All link below the tables. Next to it, there is a “With Selected” drop down, you need to click on it and choose Optimize table.
单击表格下方的检查所有链接。 在它旁边,有一个“ With Selected”下拉列表,您需要单击它并选择“ Optimize table”。

This will optimize your WordPress database by defragmenting selected tables. It will make your WordPress queries run a little faster and slightly reduce the size of your database.
这将通过对所选表进行碎片整理来优化WordPress数据库。 这将使您的WordPress查询运行得更快,并略微减少数据库的大小。
使用PhpMyAdmin修复WordPress问题 (Fixing WordPress Issues using PhpMyAdmin)
As we mentioned earlier, phpMyAdmin is a handy tool for troubleshooting and fixing some common WordPress errors and issues.
正如我们前面提到的,phpMyAdmin是一个方便的工具,用于故障排除和修复一些常见的WordPress错误和问题。
Let’s check out some common WordPress issues that can be easily fixed using phpMyAdmin.
让我们看看一些常见的WordPress问题,可以使用phpMyAdmin轻松解决这些问题。
使用PhpMyAdmin重置WordPress密码 (Reset WordPress Password Using PhpMyAdmin)
If you forgot your WordPress admin password and cannot recover it via lost password email, then this method allows you to quickly reset WordPress password.
如果您忘记了WordPress管理员密码并且无法通过丢失的密码电子邮件恢复它 ,那么此方法可让您快速重置WordPress密码。
First, launch the phpMyAdmin and select your WordPress database. This will display your WordPress database tables where you need to browse next to wp_users table.
首先,启动phpMyAdmin并选择您的WordPress数据库。 这将在wp_users表旁边显示您需要浏览的WordPress数据库表。

Note: Table names in your WordPress database may have a different table prefix than the one we are showing in our screenshot.
注意:WordPress数据库中的表名可能与我们在屏幕快照中显示的表名具有不同的表前缀。
You will now see the rows in your WordPress users table. Go ahead and click on the edit button next to the username where you want to change the password.
现在,您将在WordPress用户表中看到行。 继续,然后单击要更改密码的用户名旁边的编辑按钮。

PhpMyAdmin will show you a form with all the user information fields.
PhpMyAdmin将显示一个包含所有用户信息字段的表单。
You will need to delete the value in the user_pass field and replace it with your new password. Under the function column, select MD5 from the drop-down menu and click on the Go button.
您将需要删除user_pass字段中的值,并将其替换为新密码。 在功能列中,从下拉菜单中选择MD5,然后点击Go按钮。

Your password will be encrypted using the MD5 hash and then it will be stored in the database.
您的密码将使用MD5哈希进行加密,然后将其存储在数据库中。
Congratulations! You have successfully changed your WordPress password using phpMyAdmin.
恭喜你! 您已经使用phpMyAdmin成功更改了WordPress密码。
Now some of you may be wondering why did we select the MD5 hash to encrypt the password.
现在,有些人可能想知道为什么我们选择MD5哈希来加密密码。
In the older version, WordPress used MD5 hash to encrypt passwords. Since WordPress 2.5, it started using stronger encryption technologies. However, WordPress still recognizes MD5 to provide backward compatibility.
在旧版本中,WordPress使用MD5哈希来加密密码。 从WordPress 2.5开始,它开始使用更强大的加密技术。 但是,WordPress仍认可MD5提供向后兼容性。
As soon as you log in using a password string stored as an MD5 hash, WordPress recognizes it and changes it using the newer encryption algorithms.
使用存储为MD5哈希的密码字符串登录后,WordPress会立即识别并使用较新的加密算法对其进行更改。
使用PhpMyAdmin向WordPress添加新的管理员用户 (Adding a New Admin User to WordPress using PhpMyAdmin)
Let’s suppose you have access to the WordPress database but not the WordPress admin area. While you can change the admin user password, it will prevent the other admin user from using their account.
假设您有权访问WordPress数据库,但不能访问WordPress管理区域。 尽管您可以更改管理员用户密码,但是它将阻止其他管理员用户使用其帐户。
An easier solution would be to add a new admin user via phpMyAdmin.
一个更简单的解决方案是通过phpMyAdmin添加新的管理员用户。
First, you need to launch the phpMyAdmin and then select your WordPress database. This will show your WordPress database tables where you need to click on the ‘Browse’ link next to wp_users table.
首先,您需要启动phpMyAdmin,然后选择WordPress数据库。 这将显示您的WordPress数据库表,您需要在其中单击wp_users表旁边的“浏览”链接。

phpMyAdmin will now show you the rows inside the wp_users table. Go ahead and click on the ‘Insert’ link from the menu on the top.
phpMyAdmin现在将向您显示wp_users表中的行。 继续,然后单击顶部菜单中的“插入”链接。

This will bring up a form that you need to fill up to add a new user to your WordPress site.
这将弹出一个表单,您需要填写该表单才能将新用户添加到WordPress网站。

Here is how you need to fill each field in this form.
这是您需要填写此表单中每个字段的方式。
- ID – You can ignore this one as this is automatically generated.
- ID –您可以忽略此ID ,因为它是自动生成的。
- user_login – This will be your WordPress username that you’ll use to login. user_login –这将是您用于登录的WordPress用户名。
- user_pass – This is your WordPress password you need to enter the password and select MD5 in the function column. user_pass –这是您的WordPress密码,您需要输入密码并在功能列中选择MD5。
- user_nicename – This is the URL friendly username you can use the as your login. user_nicename –这是URL友好的用户名,您可以将其用作登录名。
- user_email – Enter a valid email address as you may need it to recieve password reset and WordPress notification emails. user_email –输入您可能需要的有效电子邮件地址,以接收密码重置和WordPress通知电子邮件。
- user_url – Add your website URL or you can leave it blank. user_url –添加您的网站URL或将其保留为空白。
- user_registered – You need to select the CURRENT_TIME in the function column to automatically insert current time here. user_registered –您需要在功能列中选择CURRENT_TIME才能在此处自动插入当前时间。
- user_activation_key – You can leave this field blank as well it is used to approve user registeration. user_activation_key –您也可以将该字段保留为空白,用于批准用户注册。
- user_status – You can leave this field blank as well. user_status –您也可以将该字段保留为空白。
- display_name – You can enter the user’s full name as you want to be displayed on the articles. You can also leave it blank. display_name –您可以输入要在文章上显示的用户全名。 您也可以将其留空。
After filling in the form, click on the Go button to insert it into your WordPress database. PhpMyAdmin will now run the MySQL query to insert the data.
填写表格后,单击“执行”按钮将其插入WordPress数据库。 PhpMyAdmin现在将运行MySQL查询以插入数据。
We have added the user, but that user does not have an administrator user role on your WordPress site. This value is saved in another table called wp_usermeta.
我们已经添加了该用户,但是该用户在您的WordPress网站上没有管理员用户角色。 此值保存在另一个名为wp_usermeta的表中。
Before we can make this user an administrator, we will need to find the user ID. Simply click on the ‘Browse’ link next to wp_users table and you will see a row containing your newly added user with their user ID.
在使该用户成为管理员之前,我们需要找到用户ID。 只需单击wp_users表旁边的“浏览”链接,您将看到一行,其中包含新添加的用户及其用户ID。

Note down the user ID as you’ll need it in the next step.
记下用户ID,因为下一步将需要它。
Now, let’s open the wp_usermeta table by clicking on the Browse link next to it.
现在,通过单击旁边的“浏览”链接来打开wp_usermeta表。

Next, you need to click on the Insert link at the top to add a new row to the table.
接下来,您需要单击顶部的“插入”链接以向表中添加新行。

You’ll now see a form to enter a new row. This is where you’ll tell WordPress that the user you created earlier has the administrator user role.
现在,您将看到一个用于输入新行的表单。 在这里,您将告诉WordPress您之前创建的用户具有管理员用户角色。

Here is how you’ll fill in this form.
这是您填写此表格的方式。
- umeta_id – You need to leave it blank as it is automatically filled in. umeta_id –您需要将其保留为空白,因为它是自动填写的。
- user_id – Enter the user ID you copied earlier. user_id –输入您先前复制的用户ID。
- meta_key – You need to enter meta_key –您需要在此字段中输入wp_capabilities in this field. However, you may need to replace wp_capabilities 。 但是,如果您的WordPress表名称使用其他前缀,则可能需要替换wp_ if your WordPress table names use a different prefix.wp_ 。
- meta_value – You need to enter the following serialized value:meta_value –您需要输入以下序列化值:
a:1:{s:13:"administrator";s:1:"1";}
a:1:{s:13:"administrator";s:1:"1";}
Finally, click on the Go button to save your changes.
最后,单击“执行”按钮以保存您的更改。
Next, we need to add another row to define the user level. Click on the Insert link on the top menu to add another row to the usermeta table.
接下来,我们需要添加另一行以定义用户级别。 单击顶部菜单上的“插入”链接,将另一行添加到usermeta表。

Here is how you’ll fill in this form.
这是您填写此表格的方式。
- umeta_id – You need to leave it blank as it is automatically filled in. umeta_id –您需要将其保留为空白,因为它是自动填写的。
- user_id – Enter the user ID for your newly added user. user_id –输入新添加的用户的用户ID。
- meta_key – You need to enter meta_key –您需要在此字段中输入wp_user_level in this field. However, you may need to replace wp_user_level 。 但是,如果您的WordPress表名称使用其他前缀,则可能需要替换wp_ if your WordPress table names use a different prefix.wp_ 。
- meta_value – Here you need to enter meta_value –在这里,您需要输入10 as the user level value. 10作为用户级别值。
Don’t forget to click on the Go button to insert the data.
不要忘记单击“ Go”按钮以插入数据。
That’s all, you can now visit the WordPress admin area and log in with your newly added admin user.
仅此而已,您现在可以访问WordPress管理员区域并使用新添加的管理员用户登录。
通过PhpMyAdmin更改WordPress用户名 (Change a WordPress Username via PhpMyAdmin)
You may have noticed that while WordPress allow you to change user’s full name or nickname, it does not allow you to change the username.
您可能已经注意到,虽然WordPress允许您更改用户的全名或昵称,但不允许您更改用户名。
Now a lot of users end up choosing usernames during the installation that they may later want to change. Here is how you can do this via phpMyAdmin.
现在,许多用户最终在安装过程中选择了可能稍后要更改的用户名。 这是您可以通过phpMyAdmin执行的操作。
Note: there is an easier way to change WordPress username using a plugin.
注意:有一种使用plugin更改WordPress用户名的简便方法。
First, you need to launch the phpMyAdmin from your hosting account’s cPanel dashboard. After that, you need to select your WordPress database.
首先,您需要从托管帐户的cPanel仪表板启动phpMyAdmin。 之后,您需要选择WordPress数据库。
PhpMyAdmin will show your WordPress database tables. You need to click on the ‘Browse’ link next to wp_users table.
PhpMyAdmin将显示您的WordPress数据库表。 您需要点击wp_users表旁边的“浏览”链接。

This table will now list all the registered users on your website. Click on the edit link next to the username that you want to change.
现在,此表将列出您网站上的所有注册用户。 单击您要更改的用户名旁边的编辑链接。

PhpMyAdmin will now show you the user data. You need to locate the user_login field and change the value to the username you want to use.
现在,PhpMyAdmin将向您显示用户数据。 您需要找到user_login字段并将值更改为要使用的用户名。

Don’t forget to click on the Go button to save your changes. You can now visit your website and login with your new username.
不要忘记单击“执行”按钮以保存更改。 现在,您可以访问您的网站并使用新的用户名登录。
其他有用的PhpMyAdmin技巧 (Other Useful PhpMyAdmin Tricks)
Your WordPress database is the engine behind your website. With phpMyAdmin you can tweak settings to improve performance, fix issues, or simply change things that cannot be changed from inside WordPress admin area.
WordPress数据库是网站背后的引擎。 使用phpMyAdmin,您可以调整设置以提高性能,解决问题或仅更改WordPress管理区域中无法更改的内容。
Following are just a few more tricks you can use with phpMyAdmin.
以下是可以与phpMyAdmin一起使用的其他一些技巧。
- Deactivate all WordPress plugins停用所有WordPress插件
- Change WordPress theme via phpMyAdmin通过phpMyAdmin更改WordPress主题
- Duplicate WordPress database via phpMyAdmin通过phpMyAdmin复制WordPress数据库
- Find and replace text in WordPress database在WordPress数据库中查找和替换文本
保护您的WordPress数据库 (Securing your WordPress Database)
Before we get into this, we want to emphasize that every site can be hacked. However, there are certain measures you can take to make it a little harder.
在进行讨论之前,我们要强调,每个站点都可以被黑客入侵。 但是,您可以采取某些措施使其变得更难一点。
First thing that you can do to is to change WordPress database prefix. This can significantly reduce the chances of SQL injection attacks on your WordPress database because often hackers target sites in masses where they are targeting the default wp_ table prefix.
您可以做的第一件事是更改WordPress数据库前缀 。 这可以显着减少对WordPress数据库进行SQL注入攻击的机会,因为黑客经常将大量目标锁定在默认wp_表前缀为目标的站点上。
You should always choose a strong username and password for your MySQL user. This will make it difficult for someone to get access to your WordPress database.
您应该始终为MySQL用户选择一个强用户名和密码。 这将使某人很难访问您的WordPress数据库。
For WordPress security, we strongly recommend that you use Sucuri. It is the best WordPress security plugin that would catch any attempts at MySQL injection even before it reaches your website.
为了WordPress安全,我们强烈建议您使用Sucuri 。 这是最好的WordPress安全插件 ,即使在未注入MySQL注入您的网站之前,它也可以捕获任何尝试。
We hope that this guide helped you learn WordPress database management and how to use phpMyAdmin.
我们希望本指南可以帮助您学习WordPress数据库管理以及如何使用phpMyAdmin。
If you are the sort of person who likes to learn how things work behind the scenes, then you would love our guides on how WordPress actually works and how WordPress plugins work.
如果您是那种喜欢学习事物在幕后工作的人,那么您会喜欢我们有关WordPress实际工作方式和WordPress插件工作方式的指南 。
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.
如果您喜欢这篇文章,请订阅我们的YouTube频道 WordPress视频教程。 您也可以在Twitter和Facebook上找到我们。