简体   繁体   中英

MYSQL restore command saying I'm trying to restore to a different database?

Hey guys I'm trying to restore a database called "hs" but MYSQL is saying, I'm trying to restore a database "mysql"

I've su root to get super user access,

[root@server init.d]# sudo mysql -u hs -p --database=hs < /home/hs/blankhsdb.sql
Enter password:

ERROR 1044 (42000) at line 1: Access denied for user 'hs'@'localhost' to database 'mysql'

Why could this be happening?

You interchange the variables there..you used 'hs' for user which is in your case, a database.

mysql -u #username# -p #database# < #dump_file#

Read this example syntax here..

http://www.techiecorner.com/31/how-to-restore-mysql-database-from-sql-dump-file/

Fixed it,

sudo mysql --database=hs < /path/to/filename.sql

maybe just a case of it getting confused as username and db are the same

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