1. Why does PHP select MySql as the database?
2. Create a user for the MySQL database
This article mainly describes the differences between the statements used to create users in MySQL and convert them from isher Blogspot. Because I thought about why I didn't use other databases, I searched why Google chose MYSQL as the database for PHP and did not find any relevant reports. I decided to find the cause, and I personally thought that, does not represent the opinions of the majority of PHP laruence groups.
Why does PHP select MySql as the database?
MySQL is the earliest open-source database (developed based on the GPL and gpl2 open-source protocols and enjoys the sharing principle. Some of them have been planned for commercial use). Although it is free of charge, however, the performance and stability are not inferior to those of other commercial databases, while PhP is the most similar to the C LanguageProgramIt has a low threshold and is independent from any commercial servers for free module release. It has good scalability. There are many open source class libraries on the Internet for PHP developers to use, as a result, PHP developers start to use the MySQL database developed based on the same GPL Convention as a low-cost partner.
2. Add a user to MySQL
For personal lessons, when adding a MySQL account, you must quote the username and host (local and %). Otherwise, the command is wrong.
Command method. Note that each line is followed by one; indicates that a command statement ends.
Format: grant select on database. * to "username" @ "Login host" identified by "password ";
Example 1: Add a user named "test1" with the password "ABC" so that the user can log on to any host and have the permission to query, insert, modify, and delete all databases. First, use the root user to connect to MySQL, and then type the following command:
Grant select, insert, update, delete on *. * to "test1" @ "%" identified by "ABC ";
Add all permission statements:
Run the following command in Example 1: Select, insert ,....) changed to "all privileges", which indicates that all permissions are granted, including database creation permissions and database deletion permissions, and are no longer limited to operations in one database.
Grant all privileges on *. * To 'root' @ '% 'identified by '123 ';
In example 1 (not supplemented), it is very dangerous to add users because your host is %, % Represents the host at any location, and local represents the meaning of "local". If, if someone wants to know the password of test1, he can connect to your MySQL database on any computer on the Internet and do whatever he wants for your data. For the solution, see Example 2.
According to the supplementary statement in Example 1, this statement should not be used on the MySQL server. If your server is hosted or remote, if you need to remotely manage the MySQL server, however, if you do not want to log on to the server through a Super Terminal, you have to use this statement, but you must be aware that you can use this method to connect to the server, and other users can, so keep your MySQL password safe.
Example 2: Add a user named "Test2" with the password "ABC" so that the user can only log on to localhost, you can also 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 the user knows the password of Test2, he cannot access the database directly from the Internet, but can only access the database through the web pages on the MySQL host.
Grant select, insert, update, delete on mydb. * to "Test2" @ localhost identified by "ABC ";
If you do not want Test2 to have a password, you can run another command to remove the password.
Grant select, insert, update, delete on mydb. * to "Test2" @ localhost identified "";
Grant select, insert, update, delete on Dez. * to "Test2" @ "%" identified by "123456 ";