Import and insert sql.gz file into database with putty

后端 未结 8 871
再見小時候
再見小時候 2021-01-30 00:12

I want to insert a sql.gz file into my database with SSH. What should I do?

For example I have a database from telephone numbers that name is numbers.

8条回答
  •  佛祖请我去吃肉
    2021-01-30 00:43

    For an oneliner, on linux or cygwin, you need to do public key authentication on the host, otherwise ssh will be asking for password.

    
    gunzip -c numbers.sql.gz | ssh user@host mysql --user=user_name --password=your_password db_name
    

    Or do port forwarding and connect to the remote mysql using a "local" connection:

    ssh -L some_port:host:local_mysql_port user@host

    then do the mysql connection on your local machine to localhost:some_port.

    The port forwarding will work from putty too, with the similar -L option or you can configure it from the settings panel, somewhere down on the tree.

提交回复
热议问题