是否有任何命令可以从另一个数据库MySQL创建数据库副本

yuvru6vn  于 2023-02-11  发布在  Mysql
关注(0)|答案(1)|浏览(144)

是否可以在mysql中使用commant从另一个数据库创建副本而不使用sql文件
我试过这个命令

mysqldump -u username -p old_database | mysql -u username -p new_database
mysqldump: Got error: 1045: Access denied for user 'root'@'localhost' (using password: YES) when trying to connect

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
lakhendrakushwah@LAKHENDRAs-MacBook-Air ~ % sudo -s 
Password:
root@LAKHENDRAs-MacBook-Air ~ # mysqldump -u root -p lakha | mysql -u root -p testDB
Enter password: Enter password: 
mysqldump: Got error: 1045: Access denied for user 'root'@'localhost' (using password: YES) when trying to connect

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
root@LAKHENDRAs-MacBook-Air ~ # mysqldump -u root -p lakha | mysql -u root -p testDB
Enter password: Enter password: 
mysqldump: Got error: 1045: Access denied for user 'root'@'localhost' (using password: YES) when trying to connect
madhu@cool

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

jdgnovmf

jdgnovmf1#

这是可能的,但您必须在同一命令中提供密码。
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES):错误是由于命令本身未指定密码。
试试看!

mysqldump -u username -p'your_password' old_database | mysql -u username -p'your_password' new_database

***注:**new_database如果不存在,则必须首先使用CREATE DATABASE创建。

相关问题