cpanel mysql

tech2022-09-14  95

cpanel mysql

This article is part of a series created in partnership with SiteGround. Thank you for supporting the partners who make SitePoint possible.

本文是与SiteGround合作创建的系列文章的一部分。 感谢您支持使SitePoint成为可能的合作伙伴。

WordPress’ success owes much to its quick and simple five-minute installation procedure. Yet the MySQL database still causes confusion for many.

WordPress的成功很大程度上归功于其快速简单的五分钟安装过程。 然而,MySQL数据库仍然使许多人感到困惑。

This tutorial describes how to create a database using cPanel, a popular platform management utility offered by many web hosts. We’ll also discuss how to use this database during a WordPress installation. The techniques can be used by any web application which requires MySQL.

本教程描述了如何使用cPanel创建数据库, cPanel是许多Web主机提供的流行平台管理实用程序。 我们还将讨论在WordPress安装过程中如何使用此数据库。 该技术可由需要MySQL的任何Web应用程序使用。

Let’s start with the basics and terminology…

让我们从基础和术语开始……

什么是数据库? (What is a Database?)

A database is a collection of organized data. That’s it. WordPress stores all its page, post, category and user data in a database.

数据库是组织数据的集合。 而已。 WordPress将其所有页面,帖子,类别和用户数据存储在数据库中。

MySQL is a database management system (DBMS). It is software which allows you to create, update, read and delete data within a database. A single MySQL installation can manage any number of self-contained databases. You could have one for WordPress, another for Magento, and others for Drupal or whatever you need.

MySQL是一个数据库管理系统(DBMS)。 它是允许您在数据库中创建,更新,读取和删除数据的软件。 单个MySQL安装可以管理任意数量的独立数据库。 您可以为WordPress提供一个,为Magento提供另一个,为Drupal或您需要的任何一个。

There are plenty of alternatives but MySQL became popular for several reasons:

有很多替代方法,但是MySQL之所以流行,有几个原因:

it is free, open source software. It is now owned by Oracle but there are open MySQL-compatible options such as MariaDB.

它是免费的开源软件。 它现在归Oracle所有,但是有开放MySQL兼容选项,例如MariaDB 。

it became synonymous with PHP – the web’s most-used language/runtime which powers WordPress. Both PHP and MySQL appeared in the mid-1990s when web development was in its infancy.

它成为PHP的同义词-PHP是Web上最常用的语言/运行时。 当Web开发处于初期时,PHP和MySQL都出现在1990年代中期。

it adopts Structured Query Language (SQL) – a (fairly) standard language for creating data structures and data.

它采用结构化查询语言(SQL)–一种(相当)标准的语言来创建数据结构和数据。

it is fast, simple to install and has many third-party development tools.

它快速,易于安装,并具有许多第三方开发工具。

应用程序如何访问数据库? (How do Applications Access a Database?)

Applications such as WordPress access their data via a database connection. In the case of MySQL, WordPress’ PHP code can only establish a connection when it knows:

诸如WordPress之类的应用程序通过数据库连接访问其数据。 对于MySQL,WordPressPHP代码只有在知道以下情况时才能建立连接:

the address where MySQL is installed

安装MySQL的地址 the name of the database it needs to access

它需要访问的数据库的名称 a user ID and password required to access that database

访问该数据库所需的用户标识和密码

A database “user” account must be defined for WordPress use. It can have a very strong password and set appropriate database permissions.

必须为WordPress使用定义一个数据库“用户”帐户。 它可以具有非常强的密码并设置适当的数据库权限。

数据如何存储? (How is Data Stored?)

MySQL and other SQL databases store data in relational tables.

MySQL和其他SQL数据库将数据存储在关系表中。

For example, you may have a set of article posts. Each post will have unique data, such as the title and body text. It will also have data used in other posts, such as the category and author details. Rather than repeat the same data again and again, we create separate tables:

例如,您可能有一组文章。 每个帖子都会有唯一的数据,例如标题和正文。 它还将具有其他帖子中使用的数据,例如类别和作者详细信息。 我们创建一个单独的表,而不是一次又一次地重复相同的数据:

an author table containing an ID, the author’s name and other details

一个包含ID,作者姓名和其他详细信息的author表

a category table containing an ID and the category name

包含ID和类别名称的category表

a post table containing the article title and body text. It would point to the author and category by referencing the associated ID number.

一个包含文章标题和正文的post表。 它将通过引用关联的ID号指向作者和类别。

SQL databases implement safeguards to guarantee data integrity. You should not be able to reference an author ID which does not exist or delete a category used by one or more articles.

SQL数据库实施保护措施以保证数据完整性。 您应该不能引用不存在的作者ID或删除一个或多个文章使用的类别。

These table definitions and rules form a database schema. A set of SQL commands execute during WordPress installation to create this schema. Only then are the tables ready to store data.

这些表定义和规则形成数据库模式 。 在WordPress安装期间执行一组SQL命令以创建此架构。 只有这样,表才可以存储数据。

如何建立资料库 (How to Create a Database)

Web hosts using cPanel provide a web address (such as https://site.com/cpanel), and a user ID and password to gain access. Keep these details safe. Do not confuse them with the database or WordPress user credentials!

使用cPanel的Web主机提供一个网址(例如https://site.com/cpanel )以及用于访问的用户ID和密码。 确保这些细节安全。 不要将它们与数据库或WordPress用户凭证混淆!

If you’re looking for a host that supports cPanel, try SiteGround, our web host of choice. All plans support cPanel, and they’ve re-skinned the dashboard to organize everything in a more friendly way.

如果您正在寻找支持cPanel的主机,请尝试我们的Web主机SiteGround 。 所有计划都支持cPanel,并且重新调整了仪表板的外观,以便以更友好的方式组织一切。

You view may look a little different but locate the DATABASES section or enter “MySQL” in the search box.

您查看的外观可能有些不同,但是找到“数据库”部分或在搜索框中输入“ MySQL”。

Click the MySQL Database Wizard and follow the steps:

单击“ MySQL数据库向导”,然后执行以下步骤:

步骤1:选择一个数据库名称 (Step 1: Choose a Database Name)

Your database requires a name:

您的数据库需要一个名称:

The name may have a prefix applied, such as mysite_. Enter an appropriate name such as blog or wordpress and hit Next Step.

该名称可能已应用前缀,例如mysite_ 。 输入适当的名称,例如blog或wordpress然后单击“ 下一步” 。

步骤2:创建数据库用户 (Step 2: Create a Database User)

You must now define the MySQL user account which WordPress uses to access your database:

现在,您必须定义WordPress用于访问数据库MySQL用户帐户:

Note the user name may also have the same prefix applied (mysite_). In this screenshot, our user ID is mysite_blogDBuser.

注意,用户名可能也应用了相同的前缀( mysite_ )。 在此屏幕快照中,我们的用户ID为mysite_blogDBuser 。

cPanel will ensure you enter a strong password. The password can be complex; you will use it only once during WordPress installation. I recommend the random Password Generator:

cPanel将确保您输入一个强密码。 密码可能很复杂; 在WordPress安装期间,您只能使用一次。 我建议使用随机密码生成器 :

Make sure you copy the user ID and password to a text file or another safe place before hitting Create User.

在点击“ 创建用户”之前,请确保将用户ID和密码复制到文本文件或其他安全位置。

步骤3:设置数据库用户权限 (Step 3: Set the Database User Privileges)

The user created above requires full access to the database during WordPress installation. It runs scripts to create tables and populate them with the initial data.

上面创建的用户需要在WordPress安装期间完全访问数据库。 它运行脚本来创建表并用初始数据填充它们。

Check ALL PRIVLEGES then hit Next Step:

检查所有原则,然后点击下一步 :

cPanel will confirm creation of the MySQL database and user.

cPanel将确认MySQL数据库和用户的创建。

MySQL数据库面板 (The MySQL Databases Panel)

You can use the MySQL Databases panel instead of the wizard. It still allows you to create a database and user, but you then add that user to the database.

您可以使用MySQL数据库面板代替向导。 它仍然允许您创建数据库和用户,但是您随后将该用户添加到数据库中。

It also provides facilities to update, repair and delete databases and users.

它还提供了更新,修复和删除数据库及用户的功能。

如何安装WordPress (How to Install WordPress)

Your cPanel may provide WordPress and other application installers. It may not be necessary to follow the steps above because the script creates a database for you.

您的cPanel可能会提供WordPress和其他应用程序安装程序。 可能不需要执行上述步骤,因为脚本会为您创建一个数据库。

If manual installation is necessary or preferred, download WordPress and extract the files. You may be able to do this on your server via SSH but FTP/SFTP is also supported.

如果需要手动安装或首选手动安装,请下载WordPress并解压缩文件。 您也许可以通过SSH在服务器上执行此操作,但也支持FTP / SFTP。

Open a browser and navigate to the domain/path where you copied WordPress, (i.e. http://mysite.com/). This starts the installation:

打开浏览器,然后导航到将WordPress复制到的域/路径(即http://mysite.com/ )。 这将开始安装:

You must enter:

你必须输入:

the MySQL Database Name created in step 1

在步骤1中创建MySQL 数据库名称

the MySQL database Username created in step 2

在步骤2中创建MySQL数据库用户名

the MySQL database user’s Password created in step 2

在步骤2中创建MySQL数据库用户的密码

the Database Host. This is the address of the server where MySQL runs. It will often be localhost or 127.0.0.1 because MySQL is running on the same server where your site is hosted. Your host will advise you if this is different.

数据库主机 。 这是运行MySQL的服务器的地址。 它通常是localhost或127.0.0.1因为MySQL在承载您站点的同一服务器上运行。 如果不同,您的房东会通知您。

The Table Prefix adds a short string to the start of all table names. Change it when:

表前缀在所有表名的开头添加了一个短字符串。 在以下情况下进行更改:

You want to install many copies of WordPress which all point to the same database, and/or

您要安装许多WordPress副本,它们都指向同一数据库,并且/或者 You want to make your installation a little more secure by making table names less obvious.

您想通过使表名不那么明显来使安装更加安全。

Hit Submit and WordPress will verify your credentials before continuing installation.

点击Submit ,WordPress将在继续安装之前验证您的凭据。

创建一个WordPress用户 (Create a WordPress User)

WordPress prompts for the ID, password and email address of a WordPress administrator. This is someone responsible for managing WordPress. It is different to the MySQL database and cPanel credentials!

WordPress会提示您输入WordPress管理员的ID,密码和电子邮件地址。 这是负责管理WordPress的人员。 它与MySQL数据库和cPanel凭据不同!

Hit Install WordPress and the dashboard will appear within a few seconds.

点击Install WordPress ,仪表板将在几秒钟内出现。

奖金安全步骤 (Bonus Security Step)

We granted full permission to the database user for WordPress installation. You can downgrade these privileges after installation to improve security.

我们授予数据库用户WordPress安装的完全权限。 您可以在安装后降级这些特权以提高安全性。

The following rights should be adequate:

以下权利应足够:

SELECT

选择 INSERT

插 UPDATE

更新 DELETE

删除 ALTER

改变 CREATE TABLE

创建表 DROP TABLE

滴台 INDEX

指数

Some plug-ins may need extra rights so enable ALL PRIVILEGES if you encounter problems.

某些插件可能需要额外的权限,因此如果遇到问题,请启用“ 所有特权” 。

翻译自: https://www.sitepoint.com/how-to-create-wordpress-mysql-databases-on-cpanel/

cpanel mysql

相关资源:jdk-8u281-windows-x64.exe
最新回复(0)