Hi..
I had used the following command to restore a mysql database on command line.


mysql -u root -p admin test < D:\backup\test.sql


here username-root,password-admin,database-test,backupfile located at-D:\backup\test.sql.

It doesnot working..showing error messages..If anybody knows plz help me.
Thanks

Dani AI

Generated

As noted, the restore failed because the password was supplied incorrectly on the command line: the MySQL client expects the password immediately after -p (no space) or -p by itself to trigger a prompt. confirmed that changing that fixed the problem, and ’s request for the exact error was the right first troubleshooting step.

Correct usage examples (placeholders used here):

mysql -u myuser -pmypassword mydatabase < "C:\path\to\backup.sql"

or, safer, prompt for the password:

mysql -u myuser -p mydatabase < "C:\path\to\backup.sql"

The second form stops the password appearing in process listings.

Other common pitfalls and fixes:

  • Windows paths with spaces must be quoted (see examples above).
  • Confirm the dump file exists and the MySQL client binary is in your PATH or call the full path to mysql.exe.
  • Ensure the MySQL server is running and the account has privileges to the target database. If the dump contains CREATE DATABASE and USE statements, the import can be run without naming a database:
    mysql -u myuser -p < "C:\path\to\backup.sql"

Security and better workflows:

  • Avoid embedding passwords on the command line where other users could read them. Use -p to be prompted, a client option file (e.g., a ~/.my.cnf or Windows equivalent with a [client] section), or mysql_config_editor / login-path features to store credentials securely:
    [client]
    user=myuser
    password=secret

Checklist summary: verify correct -p usage, confirm file path/quoting, ensure server and privileges are OK, and prefer prompting or secure credential storage rather than putting passwords on the command line.

Recommended Answers

All 3 Replies

What are the error messages ?

remove the space between the -p and the password.

Thanks for ur help .Now it is solved....I removed the space character

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.