How do I import an SQL file using the command line in MySQL?

后端 未结 30 2293
不知归路
不知归路 2020-11-22 06:48

I have a .sql file with an export from phpMyAdmin. I want to import it into a different server using the command line.

I have a Windows Ser

30条回答
  •  攒了一身酷
    2020-11-22 07:17

    For backup purposes, make a BAT file and run this BAT file using Task Scheduler. It will take a backup of the database; just copy the following line and paste in Notepad and then save the .bat file, and run it on your system.

    @echo off
    for /f "tokens=1" %%i in ('date /t') do set DATE_DOW=%%i
    for /f "tokens=2" %%i in ('date /t') do set DATE_DAY=%%i
    for /f %%i in ('echo %date_day:/=-%') do set DATE_DAY=%%i
    for /f %%i in ('time /t') do set DATE_TIME=%%i
    for /f %%i in ('echo %date_time::=-%') do set DATE_TIME=%%i
    
    "C:\Program Files\MySQL\mysql server 5.5\bin\mysqldump" -u username -ppassword mysql>C:/%DATE_DAY%_%DATE_TIME%_database.sql
    

提交回复
热议问题