The beginner in the MySQL initialization step must be familiar with the problem that PHP cannot connect to the database just now when using MySQL. Now, let's take a look at the work to be done, on the premise that you have added the mysql working directory to the environment variable. The initialization procedure is as follows: Set the password for the root user: [SQL] mysqladmin-u root password 'new-password' Replace "new-password" in the command line with the new password ". Delete anonymous users: [SQL] # mysql-u root-p mysql> use mysql> delete from user where User = ''; mysql> quit when MySQL is installed, it automatically creates two databases. One is the mysql table, which controls the user, host, and DB permissions after the server is put into use. The other is the test database. MySQL's default configuration allows any user to access the system without providing the user name and password. Reload: [SQL] mysqladmin-u root-p reload now, your MySQL can be accessed through PHP Web.