How to Reset MySQL root password:
To reset it, see How to Reset the Root Password in the MySQL manual.
How to run MySQL without password controlled access
To run MySQL with the password controls disabled, check out the --skip-grant-tables option.
How to avoid typing credentials on the command line
If you simply want to avoid having to type the password on the mysql command line, create a file called .my.cnf (note leading period on that filename!) in your home directory. In your case, for the root user, probably /root
Add the following entries to the file
[client]
host=localhost
user = root
password = mypassword
database = mydatabase
You'd typically chmod 600 this file so that only you can see it, and MySQL will ignore a .my.cnf which is world writable anyway.
See the manual page Using Option Files for more information
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…