To install WordPress, you need a MySQL or MariaDB database, a dedicated database user, and the connection values in wp-config.php. Check the server requirements, create the database and user through your host or SQL, grant the appropriate permissions, configure WordPress, then open /wp-admin/install.php to finish the site setup.
Antihost offers managed WordPress hosting with free migration, one-click staging and a 14-day free trial.
What WordPress needs before you create a database
WordPress stores posts, pages, settings, users, comments, plugin data and other structured content in MySQL or MariaDB. The database is separate from the WordPress PHP files, so both parts must be available and able to communicate through the hosting account.
As an Amazon Associate I earn from qualifying purchases.
WordPress’s “Before You Install” guidance, updated October 14, 2026, lists these minimum requirements:
- PHP 7.4 or greater.
- MySQL 5.7 or greater, or MariaDB 10.3 or greater.
- HTTPS support for the site.
Ask your hosting provider for the database server name, database port, database host value, and whether it expects a Unix socket. Do not assume that localhost is correct: it is common on traditional shared hosting, but providers can require another hostname, a non-default port or a socket path.
#1 Best Overall
Choose the database setup method
The result is the same regardless of the interface: one database, one WordPress database user, and a grant that lets that user work on the selected database. The practical difference is how much control you have.
| Route | Best for | What you need to know |
|---|---|---|
| Hosting control panel | Most shared-hosting installations | Use the provider’s database wizard, often in cPanel, Plesk or DirectAdmin. The host may automatically create the user, grant access and add a required account-name prefix. |
| phpMyAdmin | Administrators who prefer a browser interface | Create the database, create a separate user, then assign that user to the database with the required privileges. |
| MySQL client | VPS, dedicated servers and shell-based deployments | Run SQL as an account allowed to create databases and users. You must supply the correct host value and manage grants yourself. |
| Provider-managed database | Hosting plans that automate database provisioning | Copy the provider’s database name, username, password and host exactly. Some services do not permit arbitrary database names or users. |
| WP-CLI | Repeatable command-line deployments | With a valid wp-config.php, wp db create issues the database-creation statement using its configured connection values. |
A single WordPress site normally gets its own database. If your host limits the number of databases, several sites can share one database when each installation uses a distinct table prefix. Keep the prefix unique and record which prefix belongs to each site; otherwise, maintenance or a mistaken import can affect another installation.
Recommended Free Tools
Plan the names, host and character settings
Database and user names
Choose names that identify the site without exposing unnecessary information. Use a different database user for each installation rather than reusing an administrator account across sites. Shared hosts frequently prepend the hosting-account username, so a database entered as blog may become something like account_blog. The final prefixed name is the value that belongs in DB_NAME.
Database host
DB_HOST is the address WordPress uses to reach MySQL. localhost is typical when PHP and MySQL run on the same server, but a managed or remote database may provide a DNS hostname. If the provider gives a port, include it in the host value in the format the provider documents. If it supplies a Unix socket, use that socket path instead of guessing.
Character set and collation
WordPress’s database-creation guidance recommends the utf8 series and suggests utf8mb4_general_ci when an appropriate language-specific collation is not available. Leave the DB_CHARSET and DB_COLLATE constants at their defaults unless you understand the consequences of changing them. A collation affects sorting and comparisons, so selecting one merely because its name looks familiar can produce unexpected results for multilingual content.
Create the database in a hosting control panel
The labels vary, but the workflow is consistent in cPanel, Plesk, DirectAdmin and similar panels.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →- Sign in to the hosting control panel and open the section named MySQL Databases, Databases or an equivalent database manager.
- Create a new database. Enter the short name supplied by your plan, then note the complete name including any automatic account prefix.
- Create a new MySQL user with a long, unique password. Do not reuse the hosting-login password.
- Use Add user to database, Assign user or the equivalent action to attach the new user to the WordPress database.
- When the panel offers privileges, select the option that grants the user access to that database. Record the exact database name, username, password and host shown by the panel.
- Check whether the panel reports a custom host or port. If it does, that value takes precedence over
localhost.
Some hosts create the database and user together and hide the grant step. That is acceptable as long as the resulting user is attached to the intended database and the panel displays credentials that WordPress can use.
Create the database with the MySQL client
Use this route when you have shell access and an administrative MySQL account. Replace every placeholder with a value supplied by your provider or chosen for this site. The host in the user definition must match the host from which WordPress will connect.
Rank #3
CREATE DATABASE databasename;
CREATE USER "wordpressusername"@"hostname" IDENTIFIED BY "strong-password";
GRANT ALL PRIVILEGES ON databasename.* TO "wordpressusername"@"hostname";
FLUSH PRIVILEGES;
What each statement does
CREATE DATABASEmakes the empty database that WordPress will populate.CREATE USERcreates a login restricted to the specified account name and connection host.GRANT ALL PRIVILEGES ON databasename.*gives that user access to every table in this database, not to unrelated databases.FLUSH PRIVILEGESreloads the privilege information after the grant.
Using "wordpressusername"@"localhost" when WordPress actually connects from another host creates a valid account that still cannot log in from the application server. Conversely, making the host broader than your provider requires can grant access from locations that do not need it. Use the exact host value documented for your environment.
Put the connection details in wp-config.php
WordPress’s base configuration file contains the database connection information and other site-wide settings. In the WordPress package, copy or rename wp-config-sample.php to wp-config.php, then edit the database section.
Free tools Windows power users keep installed
One-click scans. No signup required.
define( 'DB_NAME', 'database_name_here' );
define( 'DB_USER', 'username_here' );
define( 'DB_PASSWORD', 'password_here' );
define( 'DB_HOST', 'localhost' );
| Constant | Value to enter | Common mistake |
|---|---|---|
DB_NAME |
The complete database name, including a hosting-account prefix if one exists | Entering the unprefixed short name from the creation form |
DB_USER |
The complete MySQL username | Using the hosting-panel login rather than the database user |
DB_PASSWORD |
The password assigned to that database user | Leaving quotation marks out of the PHP string or copying an extra space |
DB_HOST |
The provider’s hostname, localhost, a host-and-port value, or a Unix socket path |
Assuming every server uses localhost |
Keep the existing DB_CHARSET and DB_COLLATE definitions unless you have a specific compatibility reason to alter them. Treat wp-config.php as a secret-bearing file: limit who can read it, avoid pasting it into public support forums, and remove credentials from shell history or temporary notes after use.
If several WordPress installations share one database, set a different $table_prefix for each installation in its own configuration file. A unique prefix prevents WordPress from treating another site’s tables as its own.
Rank #4
Upload WordPress and run the installer
- Upload the WordPress files to the domain’s document root or to the subdirectory where the site will live.
- Place the completed
wp-config.phpin the WordPress directory. Ensure the PHP process can read it. - Open
https://example.com/wp-admin/install.php. For a subdirectory installation, use that subdirectory in the URL. - Enter the site title, administrator account and other installer fields, then submit the form.
- WordPress creates its tables in the selected database and redirects you to the administration area when setup succeeds.
If wp-config.php is absent, WordPress can display a form asking for the database details and attempt to create the file. The web server still needs permission to write the configuration file during that step. Creating the file yourself is usually easier to audit because you can verify every value before opening the installer.
Use least privilege after the initial setup
During a first installation, many guides grant the WordPress user all privileges on its own database because plugins and updates can need schema changes. That broad grant should not automatically become the permanent operating model.
WordPress Developer Resources states: “For normal WordPress operations, such as posting blog posts, uploading media files, posting comments, creating new WordPress users and installing WordPress plugins, the MySQL database user only needs data read and data write privileges to the MySQL database; SELECT, INSERT, UPDATE and DELETE.”
Normal operation
For day-to-day requests, the account needs the ability to select, insert, update and delete rows in the WordPress database. Those permissions cover publishing, media metadata, comments and user records without allowing routine requests to alter the database structure.
Schema-changing work
Some plugins, migrations and major updates need temporary schema privileges such as ALTER or permission to create tables. WordPress hardening guidance recommends granting those rights only for the operation that needs them, then removing them afterward. Coordinate the change with your host if the control panel does not let you edit individual grants.
Practical privilege workflow
- Complete the installation with the permissions your provider requires.
- Confirm that the site can publish a post, upload media and manage users.
- Reduce the database user to normal read/write data privileges when your environment allows it.
- Before a schema-changing plugin or update, create a backup and temporarily elevate the account only as needed.
- Run the update, test the site, then restore the restricted grant.
Command-line creation with WP-CLI
WP-CLI can create the database after the connection values are present in wp-config.php. From the WordPress directory, run:
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minute$ wp db create
Success: Database created.
The wp db create command issues a CREATE DATABASE statement using DB_HOST, DB_NAME, DB_USER and DB_PASSWORD loaded from wp-config.php. The database user therefore needs permission to create the database, and the host must allow that account to connect. If your provider already created the database, do not run this command merely to test the credentials; proceed to the installer instead.
Diagnose “Error establishing a database connection”
Work through the values and permissions in a fixed order rather than repeatedly changing several settings at once.
| Symptom or situation | Check | Correction |
|---|---|---|
| WordPress rejects the connection immediately | Compare DB_NAME, DB_USER, DB_PASSWORD and DB_HOST character by character with the provider’s values. |
Correct the mismatched constant, including prefixes, capitalization and accidental spaces. |
| Credentials look right but access is denied | Confirm that the WordPress user is assigned to the selected database and that its MySQL account host matches the application server. | Attach the user to the database or recreate the grant with the provider-supplied host. |
| The database server cannot be reached | Ask whether the MySQL service is running and whether the provider uses a remote hostname, custom port or socket. | Use the documented host, port or socket in DB_HOST; restart or escalate the database service when you administer the server. |
| The panel created a name different from the one you entered | Look for the hosting-account prefix in the panel’s final database and username listings. | Copy the complete names into DB_NAME and DB_USER. |
| The installer opens but cannot create tables | Check whether the account has write access to the database and whether the database uses the intended character settings. | Repair the grant, then retry the installer after confirming the database is reachable. |
| A plugin or update fails while ordinary posts work | Determine whether the operation requires a schema change. | Temporarily grant the required schema privilege, perform the update, test it and remove the elevation. |
Verify the server-side facts
- Confirm that the MySQL or MariaDB version meets WordPress’s stated minimum.
- Confirm that PHP can reach the database host through the account’s network policy.
- Check that the database exists on the same server named in
DB_HOST; a database created on one server is not automatically visible on another. - Make sure the password in
wp-config.phpis the current password, especially after changing it in a control panel.
If the values and grant are correct but the service is unavailable, the problem is on the database server or hosting network rather than in WordPress’s installer. Your provider can confirm service status, connection limits and the correct endpoint.
Pre-install and post-install checklist
Before opening the installer
- PHP is 7.4 or newer.
- MySQL is 5.7 or newer, or MariaDB is 10.3 or newer.
- HTTPS is available for the site.
- The database exists and its complete name is recorded.
- A dedicated database user has a unique password and access to that database.
- The provider’s host, port or socket value is recorded.
wp-config.phpcontains the four matching connection constants.
After WordPress loads
- Open the dashboard and publish a test post.
- Upload a test image and verify that the media library records it.
- Create or edit a non-administrator test user if your workflow requires user management.
- Confirm that the site uses HTTPS and that the administration URL resolves correctly.
- Record the database name, user, host and table prefix in your deployment documentation without storing the password in plain text.
- Apply the least-privilege grant that your plugins and update process support.
Which setup route should you use?
Use the hosting panel when you are on shared hosting or when the provider automatically handles prefixes, grants and service endpoints. Choose SQL when you administer the server and need repeatable, auditable commands. Use WP-CLI when the site is deployed from scripts and the database account is already authorized to create databases. A provider-managed database is appropriate when the host supplies the endpoint and credentials as part of the service, but you must still copy those values exactly into WordPress.
The safest general pattern is a dedicated database per site, a dedicated user, a host value confirmed by the provider, and normal operation restricted to data read/write privileges. Shared databases and temporary privilege elevation are workable alternatives when hosting limits or update requirements make them necessary, provided each site has a unique table prefix and elevated access is removed after schema work.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




