简体   繁体   中英

Restoring mysql backup without users

I have a confusion actually. While restoring the mysql backups, we generally use this command.

mysql -u username -p password databasename < backup.sql.

I just tried "mysql databasename < backup.sql" and that seemed to work too. So my confusion is, why do we add username / pass and what are the benefits / disadvantages of using / not using it?

If your MySQL doesn't have blank user and blank password then you couldn't able to import the database. By default- Mysql installation comes with blank username and password in that case you can restore database without username and password only.

But if you have secure installation of mysql, means removed bkank user than you need to pass privileged username and password to restore the database.

While using mysql command for importing database, you can use either full command or skip some of the parameters.

You can also use :

mysql -u username -p password < backup.sql

This will create the database (if your dump have create database command) and import the tables into that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM