1. Why does PHP choose mysql as its database?
2. Create user for Mysql database
This article mainly writes about the difference in the statement of MySQL to create a user. 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 information. Report, Bian 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 of the existing parts have been planned for commercial use). Although it is free, it does not compare at all in terms of performance and stability. It is not inferior to other commercial databases, and PHP, as the program most similar to C language, has a low threshold, and is released as a free module without relying on any commercial server. It has good scalability and there are many open source classes on the Internet. The library is provided for PHP developers to use, so 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. It is no longer limited to one database. Internal operation
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456';
The added users in Example 1 (non-supplementary) are very dangerous, because your host is %, % means a host in any location, and local means "local". If someone wants to know test1's password, then he can connect to your mysql database on 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 one thing should be clear, 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 MYSQL database The host where it 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";