Do you already have PHP on VPS then but that app only allows you to execute PHP files only, not to be installed WordPress because you will need to add a very important application is to support MySQL database storage WordPress website where you will install it next.
Contents content
I. How to install MySQL on VPS
II. Create database and database user on VPS
Login to MySQL
2.1) command to create database
2.2) command to create a user database
2.3) Granting access to the database user to the database
Epilogue
I. How to install MySQL on VPS
Installing MySQL is very easy, we would still use yum to install the package. You run the following command to install MySQL:
1
| sudo yum install mysql-server y |
Then restart MySQL (service name is mysqld):
1
| sudo service mysqld start |
And it appears a lot of information like this:
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
| [Thach @ vpscanban ~] $ sudo service mysqld start Initializing MySQL database: WARNING: The host 'vpscanban' could not be Looked up with resolveip. This lẽ Furniture Ad nghĩa libc libraries are not 100% compatible with this binary MySQL version. The MySQL daemon, mysqld, shouldnt work Normally with the exception Furniture resolving host names sẽ not work. This nghĩa Furniture shouldnt you use IP addresses, hostnames thay khi chỉ MySQL privileges! Installing MySQL system tables ... OK Filling help tables ... OK To start mysqld at boot time you have to copy support-files / mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER! To do so, start the server, then issue the theo commands: / Usr / bin / mysqladmin u root password 'new-password' / Usr / bin / mysqladmin u root -h vpscanban password 'new-password' Alternatively you can run: / Usr / bin / mysql_secure_installation sẽ am also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers. See the manual for more dẫn. You can start the MySQL daemon with: cd / usr; / Usr / bin / mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl cd / usr / mysql-test; perl mysql-test-run.pl Please report any problems at http://bugs.mysql.com/ [OK] Starting mysqld: [OK] |
This means that we only install MySQL on but not set up for it, besides, we still lack a very important information which is MySQL Root Password . MySQL Root Password is the password for the database user name to log into the MySQL root.
Do not confuse the root password for the MySQL root password and VPS, the two are completely different.
To set up, you run the following:
1
| sudo / usr / bin / mysql_secure_installation |
First, it asks:
1
| Enter current password for root (enter for none): |
Because you have not set the root password for MySQL should press the Enter key without entering anything.
It will continue to ask you want to set a password for user root or not, type y and enter.
1
| Set the root password? [Y / n] y |
Eventually it will ask you to add 4 more questions, just press Y and then Enter all.
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
| By default, a MySQL installation has an anonymous user, either, allowing anyone to log into MySQL without having to have a user account created for add. This is Intended only for testing, and to make the installation go a bit smoother. Remove add Cần before moving into a production environment. Remove anonymous users? [Y / n] y ... Success! Normally, root shouldnt only be allowed to connect from '<a This Furniture ensures someone can not guess at the root password from the network. Disallow root login remotely? [Y / n] y ... Success! By default, MySQL comes with a database named 'test' that anyone can access. This is Cũng Intended only for testing, and nên removed before moving into a production environment. Remove test database and access to it? [Y / n] y - Dropping test database ... ... Success! - Removing privileges on test database ... ... Success! Reloading the privilege tables Furniture Will Ensure all changes made so far Will take effect IMMEDIATELY. Reload privilege tables now? [Y / n] y ... Success! Cleaning up ... All done! If you've completed all of the above steps, MySQL Ad shouldnt now be secure installation. Thanks for using MySQL |
Okay, okay restart MySQL.
1
| sudo service mysqld restart |
Now you've got a MySQL Server on VPS and have the MySQL root password then. Try to log into MySQL with the following command:
1
| sudo mysql u root -p123456 |
In particular, the root is the root user name and 123456 is the MySQL root password you just set.
If it appears that this was successful:
01
02
03
04
05
06
07
08
09
10
11
| Server version: 05.05.39 MySQL Community Server (GPL) by Remi Copyright (c) 2000, 2014, Oracle and / or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and / or its affiliates. Other names lẽ respective Trademarks of họ owners. Type 'help;' or '\ h' for help. Type '\ c' to clear the current input statement. mysql> |
Type exit; to exit.
II. Create database and database user on VPS
I guess you already know that when installing WordPress on Shared Hosting, we must create a database for it, right? Here too, we need to create a database and a database user for WordPress to connect to the data store.
Although you can use the database as the root user with the root password of MySQL, but it's too dangerous if you have many different database, simply because hackers know the MySQL root password that can take over the entire administration databases available on the VPS.
Therefore, I encourage you to use a separate database for each database user to safety.
Login to MySQL
To work with MySQL we all need to log in to the MySQL server with the command
mysql
.
1
| u root mysql -p123456 |
Maybe you do not need to write directly behind a password
-p
so you can enter it after the command execution log.
Note added in MySQL is one thing you would write in SQL, so each statement you must end with a colon (;).
2.1) command to create database
To create the database, we use the following commands in MySQL Server:
1
| CREATE DATABASE dulieu1; |
In particular, dulieu1 is that I need to create a database name. Notify the successful implementation of this form will be:
1
| Query OK, 1 row AFFECTED (0:00 sec |
To make sure that you have just created a database on the server, type the command:
1
| SHOW databases; |
Return results:
1
2
3
4
5
6
7
8
9
| + -------------------- + | Database | + -------------------- + | Information_schema.tables | | Dulieu1 | | Mysql | | Performance_schema | + -------------------- + 4 rows in set (0:00 sec) |
2.2) command to create a user database
To enhance security , MySQL does not allow unilateral application to send data directly to the hard drive, but going through the control of a user database. And to avoid using root as the user connects the user to execute commands for security reasons, we will need to create a database user for database management dulieu1 we created above.
Command creates a database user as follows:
1
| CREATE USER @ localhost dulieu1_user; |
In particular,
localhost
is the hostname of you, you should not change this unless you know what you're doing.
Now we have a user named
dulieu1_user
, you can put any name but I like this place memorable.
To make sure you have just created a user on the server, check by running the following command:
1
| SELECT User FROM mysql. users ; |
Return results:
1
2
3
4
5
6
7
8
9
| + -------------- + | User | + -------------- + | Dulieu1_user | | Root | | Root | | Root | + -------------- + 4 rows in set (0:00 sec) |
Has called the user must have a password, now we will set the password for the userdulieu1_user just created using the following command:
1
| SET PASSWORD FOR dulieu1_user @ localhost = PASSWORD ( "123456" ); |
Of these, 123 456 at the end of the command line is that you need a password for the user settings dulieu1_user .
Now you can get out of MySQL Server command
exit,
and try to log in as a user no MySQL Server that you just created.
1
| mysql u dulieu1_user -p123456 |
Then type the command
SHOW databases;
database list that it owns.
You can see that it is only right a default database called information_schema but there is no database named dulieu1 . And if it does not display the required database connections here also means that you will receive an error message when the database connection settings WordPress .
The reason is we just created on the database and database user only, but has notauthorized the use of the database user dulieu1_user dulieu1 . At the bottom we will make this work.
2.3) Granting access to the database user to the database
Please log out and log in again as root MySQL Server offline. Now here we will need to grant the user name dulieu1_user can connect to the database name dulieu1 , then we will have the following command:
1
| GRANT ALL PRIVILEGES ON dulieu1. * TO dulieu1_user @ localhost Identified BY '123456' ; |
Remember, if it shows
Query OK, 0 rows AFFECTED (0:00 sec)
, the new successful offline.
In particular, the 123456 is the password of the user dulieu1_user .
Grant finished, type the following command to re-create it to update the MySQL Server.
1
| FLUSH PRIVILEGES ; |
Ok, now the database user name dulieu1_user had access database called dulieu1then. You can try to log into MySQL Server database user with the command you just created and press
SHOW databases
display database if it has not been granted.Epilogue
So now we've got a webserver with full functionality to run a WordPress website then, still hesitate even without installing WordPress on a public website. In the following section, I will guide you how to install a WordPress website on VPS by the fastest.
0 nhận xét:
Post a Comment