Linux installed after MySQL, the default is no password, the method of setting the root password is as follows: Method One: The simplest method, but also after the installation of MySQL, the system prompt method. Use Mysqladmin to complete. shell> mysqladmin-u root password "newpwd" shell> mysqladmin-u root-h host_name password "newpwd" password the following double quotes are not required Required, but if the password contains spaces or some special symbols, you need to use quotation marks. Method Two: Use MySQL inside the Set password command to complete, note must use the password () function to encrypt the settings of this newpwd, otherwise direct = ' newpwd ' will not take effect. However, if you use the Mysqladmin password to set a password or grant to set it, you do not need to use the password () function, because they have already called the function automatically. Shell> mysql-u rootmysql> set PASSWORD for ' root ' @ ' localhost ' = PASSWORD (' newpwd ');mysql> SET PASSWORD for ' root ' @ ' host_name ' = PASSWORD (' newpwd '); Method Three: Set the password directly via the Update user table shell> mysql-u rootmysql> Update mysql.user Set Password = Password (' newpwd '), WHERE u ser = ' root ';mysql> FLUSH privileges;
Mysql Setup Password