Home >Backend Development >PHP Tutorial >my life would suck without you php Why choose mysql as the database? Mysql create user method

my life would suck without you php Why choose mysql as the database? Mysql create user method

WBOY
WBOYOriginal
2016-07-29 08:36:58983browse

1. Why does PHP choose mysql as its database?​
2. Create user for Mysql database
This article mainly writes about the differences in the statements of MySQL to create users. It is transferred from isher's blogspot. When I was writing, I thought about why not to use other databases. I searched Google why PHP chooses MySQL as the database, and found no relevant reports. I decided to find the cause. At the same time, this problem is my personal opinion and does not represent the opinions of the majority of PHP veterans. If there is anything wrong, please point it out.
Why does PHP choose mysql as its database?​
mysql is the earliest open source database (developed based on the GPL, GPL2 open source agreement, enjoying the sharing principle, and some existing parts have been planned for commercial use). Although it is free, its performance and stability are not inferior to other commercial databases. Database, and PHP, as the program most similar to the C language, has a low threshold, and is released as a free module that does not depend on any commercial server. It has good scalability. There are many open source libraries on the Internet to provide PHP developers Therefore, PHP developers can use the Mysql database also developed based on the GPL convention as a low-cost starting partner.
2. Mysql add user
Personal lesson, when adding a Mysql account, be sure to enclose the username and host (local and %) in quotation marks, otherwise the command will be wrong.
Command mode. Note that each line is followed by ; to indicate the end of a command statement.
Format: grant select on database.* to "username"@"login host" identified by "password";
Example 1. Add a user test1 with the password abc, so that he can log in on any host and have query, insert, modify, and delete permissions on all databases. First connect to MYSQL as the root user, and then type the following command:
grant select,insert,update,delete on *.* to “test1”@"%" Identified by "abc";
Add all permission statements:
From Example 1: Change the execution permissions (select, insert,....) to all privileges, which means that you have all permissions, including creating database permissions and deleting databases. You are no longer limited to operating within one database.
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456';
The user added in Example 1 (non-supplementary) is very dangerous, because your host is %, % represents a host at any location, and local means "local". If someone wants to know the password of test1, then He can connect to your MySQL database from any computer on the Internet and do whatever he wants with your data. See Example 2 for the solution.​
According to the supplementary statement in Example 1, try not to use this statement on the Mysql server. If your server is in a managed or remote zone, if you need to remotely manage the Mysql server and do not want to log in to the server through Hyper Terminal, then you have to Use this statement, but be aware of one thing, that is, you can use this method to connect to the server, and so can others, so keep your mysql password safe.
Example 2: Add a user test2 with the password abc, so that he can only log in on localhost, and can query, insert, modify, and delete the database mydb (localhost refers to the local host, that is, the host where the MYSQL database is located) ), so that even if the user knows the password of test2, he cannot directly access the database from the Internet, and can only access it through the web page on the MYSQL host.
grant select,insert,update,delete on mydb.* to “test2”@localhost identified by “abc”;
If you don’t want test2 to have a password, you can type another command to eliminate the password.​
grant select,insert,update,delete on mydb.* to “test2”@localhost identified by "";
grant select,insert,update,delete on dez.* to “test2”@"%" identified by "123456";

The above introduces my life would suck without you php. Why choose mysql as the database? Mysql creates user method, including my life would suck without you. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn