Mysql Database Import Tutorial with Examples

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/mysql-database-import-tutorial-examples/
PINTEREST
PINTEREST
INSTAGRAM

Backup and Restore operations are important part of the database administration. mysqlimport command is used to load data in file into Mysql or Mariadb servers. Mysql import is generally used by providing SQLfile.

Syntax

Syntax of mysqlimport is like below.

mysqlimport OPTIONS DBNAME FILE

  • OPTION is used provide detailed configuration
  • DBNAME is the name of the database we want to import
  • FILE is the file which contains the data and schema

Import SQL File

The first example is simply importing the data file into mysql database. We will provide the username with -u and insert into database name students the sql file named newstudents.sql .

Provide Password Interactively

We may need to provide the password for the user. We can use -p option to provide the password. In this example we will use user ismail and provide password interactively.

Provide Password Batch Mode in Clear Text

Another practical way to provide password is batch mode. But keep in mind this is a security violation for the most of the situations. We will provide the password in cleartext with -p option. In this example the password is sosecret .

Import From Mysql Interactive Shell

We can use mysql shell in order to import sql files. In order to use mysql interactive shell for sql file import we should open the shell.

LEARN MORE  How To Prevent Sql Injection in Php Applications?

Select Database

and then we will select the database we want to import given sql file.

Specify SQL File

and the last step is specifying the sql file with \. operator. The SQL file must be in a compatible format in order to complete import operation successfully.

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/mysql-database-import-tutorial-examples/
PINTEREST
PINTEREST
INSTAGRAM

You may also like...

Leave a Reply

Your email address will not be published.

Enjoy this blog? Please spread the word :)