WordPress needs a MySQL database. The database can be created in different ways, depending on which server you are using.
If you use the services of a hosting provider, then check with the provider, perhaps the database has already been created for you.
If you need to create the database yourself, then the general principle of action for all hosting providers is as follows:
Go to the hosting control panel (you received a link to the panel when registering with the hosting provider).
Find somewhere in the menu the section “Databases” or “MySQL”
Create a database in this section. For the database, you need to specify its name, and also for the database, its user is specified. If the user does not exist, then it must be created. Specify a username and password for the user.
All data must be saved: database name, username, user password. This data will be used in the wp-config.php file when installing WordPress.
To see examples of how a database is created, below are a few video tutorials on this topic:
Creating a database in cPanel:
Here is a good text guide.
Creating a database in ISPmanager:
Creating a database in DirectAdmin:
Creating a database in Plesk:
If your hosting provider has a different panel, then everything is done by analogy … As a last resort, if nothing is clear, write to those hosting support, they will help you create a database there or they will do it for you.
Creating a database in phpMyAdmin
If the hosting does not have a control panel or it does, but you cannot create a database there, then phpMyAdmin is installed on all servers and the database can be created there.
Here is a detailed video on how to do it:
Good instructions in text format →
Working with the MySQL Console
If you have shell access to the web server and are command line literate, and your MySQL user has permissions to create other MySQL users and databases, then use the instructions below to create a user and database for WordPress.
$ mysql -u adminusername -p
Welcome to the MySQL monitor. Commands end with ; or\g.
Your MySQL connection id is 5340 to server version: 3.23.54
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
mysql> CREATE DATABASE databasename;
Query OK, 1 row affected (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON databasename.* TO “wordpressusername”@”hostname”
-> IDENTIFIED BY “password”;
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)
You need to put your value in the following variables:
adminusername is most often set to root, unless you have another account with higher privileges.
wordpress or blog are appropriate names for your databasename database.
wordpress is an appropriate name for the username wordpressusername.
hostname is most often localhost. If you do not know the value of this variable, we recommend that you ask your system administrator for it.
password password – it is desirable if it will include characters presented in upper and lower case, special. symbols, numbers and letters.
Step: configuring the wp-config.php file
The WordPress distribution does not have a wp-config.php file, but there is an example of it: wp-config-sample.php. The config must be created based on this file, i.e. you need to remove the ‘-sample’ suffix, open the file in a text editor and replace the following lines there:
define(‘DB_NAME’, ‘putyourdbnamehere’); // Database name
define(‘DB_USER’, ‘usernamehere’); // MySQL username
define(‘DB_PASSWORD’, ‘yourpasswordhere’); // …and password
define(‘DB_HOST’, ‘localhost’); // 99% this line does not need to be changed
define(‘DB_CHARSET’, ‘utf8’); // usually does not change
define(‘DB_COLLATE’, ”); // usually does not change
Explanation of each parameter:
The name of the created database.
Username for WordPress.
The password you chose for the user when creating the database.
The name of the host where the database resides is almost always localhost and specifies localhost here.
Database encoding, almost always remains unchanged
The type of character comparison in the encoding specified in DB_CHARSET. Most often, the value does not require changes and remains empty
Also, be sure to change the authentication keys. These keys are used in various places in the WordPress code to protect against hacking:
define(‘AUTH_KEY’, ‘insert unique key here’);
define(‘SECURE_AUTH_KEY’, ‘insert unique key here’);
define(‘LOGGED_IN_KEY’, ‘Enter unique key here’);
define(‘NONCE_KEY’, ‘insert unique key here’);
define(‘AUTH_SALT’, ‘insert unique phrase here’);
define(‘SECURE_AUTH_SALT’, ‘insert unique phrase here’);
define(‘LOGGED_IN_SALT’, ‘Enter unique phrase here’);
define(‘NONCE_SALT’, ‘insert unique phrase here’);
In order not to compose the keys yourself, you can quickly generate them using the following link: https://api.wordpress.org/secret-key/1.1/salt/.
In principle, this prefix can not be touched, everything will work. The $table_prefix specified in the variable will be used for all created tables. Changing this prefix uniqueizes the name of the tables and in some cases can protect against hacking or at least create additional difficulties.
$table_prefix = ‘wp_’;
Since version 2.6 the wp-config.php file can be moved one directory. Those. if the file is located in the /public_html/wordpress/wp-config.php directory, it can be moved to the /public_html/wp-config.php directory.
Stage: file placement (file structure)
At this step, you need to decide in which folder to place the files. When receiving passwords from hosting, the letter usually indicates the root directory of the site – this is the folder where the link of your site leads: for example, http://example.com/ or http://example.com/blog/. If you do not understand where the root directory of the site is located, then find out in those. hosting support.
There are 3 types of WordPress file hosting.
1. WP files in root directory or subdirectory
Move the files from the installation ZIP archive to a directory on the server. Move as is, i.e. The following files will be copied:
Let’s say the URL http://example.com/ corresponds to the folder on the sites/example.com/public_html server, then all these files need to be copied to the public_html folder and then by clicking on the link http://example.com/ the installation of WordPress will begin.
If you want to place WordPress in a subfolder (let’s say blog), then you need to create this folder on the server and copy the files there, i.e. copy to: sites/example.com/public_html/blog/. In this case, the site will be under the link http://example.com/blog.