Using Putty to import sql file into database

I want to import a .sql file into a database on the server via the command line.

I understand that I should use the following line:

mysql -u username -p database database name <textfilewithsqlstatments.sql

The sql file is in my local folder, should I upload it to the server first? How do I specify a directory for this file?

thanks

+7
source share
3 answers

Line

mysql -u username -p database_name < textfilewithsqlstatments.sql 

The file is assumed to be in the same directory in which you are using the command.

You must upload the file to the server and specify the path as

 mysql -u username -p database_name < /path/to/file/on/server/textfilewithsqlstatments.sql 
+12
source

U can use putty utility PLINK.EXE

It is preferable to configure the session using the key, you do not need to enter a password in all connections, so simple use:

plink mysql -u username -p database database name <textfilewithsqlstatments.sql

Given the file

textfilewithsqlstatments.sql

located in your / home / user.

Additional information about PLINK: http://the.earth.li/~sgtatham/putty/0.58/htmldoc/Chapter7.html

It works great!

+1
source

STEP 1: enter your hostname or IP address and use port 22 @putty. If you enter your hostname, skip http: // www and just enter yourdomain.com.

STEP 2: Then you can enter your cPanel username and press Enter

STEP 3: Then enter your cPanel password and press enter.

STEP4: finally, a step to enter the command line below

 mysql -u database_user_name -p database_db_name < /home/alphabettechnologies/public_html/alphabet_webz.sql 

and press enter. (Be sure to replace the path with the correct address for your database. SQL database file name. You also need to replace it with the new username and password for the database.

 mysql -u database_user_name -p database_db_name < /home/alphabet/public_html/db-backup.sql 

STEP 5: enter the password of the database user

That's all, the database will be imported.

0
source

Source: https://habr.com/ru/post/954776/


All Articles