将数据库从本地导入至MySQL

时间:2025-04-20 09:59:53
Loading the Database
当我们download一些db文件到本地时,我们要想在mysql中看到这些db文件,需要做导入工作。
Loading and Saving Databases
To load a database file, open a command prompt, and change to the directory
that the file is stored in. Then run the following command (replacing username
and filename with the appropriate names):
【从本地导入到mysql中】
mysql -u username - p(root需要密码) < filename.db
EG:mysql -u root -p <
等到回车后提示输入密码时再输入密码
【从mysql中导入本地】
To save a database from MySQL to a file, open a command prompt and type the
following (replacing username , databasename and filename with the appropriate
names):
mysqldump -u username - p(root需要密码) -B databasename > filename.db
每次有新的db都需要按照此操作向mysql中导入。