Skip to content
Fix Code Error

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

March 13, 2021 by Code Error
Posted By: Anonymous

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 Server 2008 R2 installation. I placed the .sql file on the C drive, and I tried this command

database_name < file.sql

It is not working. I get syntax errors.

  • How can I import this file without a problem?
  • Do I need to create a database first?

Solution

Try:

mysql -u username -p database_name < file.sql

Check MySQL Options.

Note-1: It is better to use the full path of the SQL file file.sql.

Note-2: Use -R and --triggers to keep the routines and triggers of original database. They are not copied by default.

Note-3 You may have to create the (empty) database from mysql if it doesn’t exist already and the exported SQL don’t contain CREATE DATABASE (exported with --no-create-db or -n option), before you can import it.

Answered By: Anonymous

Related Articles

  • Remove privileges from MySQL database
  • How to remove MySQL completely with config and…
  • phpMyAdmin on MySQL 8.0
  • Obtain most recent value for based on index in a…
  • Forbidden :You don't have permission to access…
  • Get operating system info
  • PHP parse/syntax errors; and how to solve them
  • Fix top buttons on scroll of list below
  • How to secure phpMyAdmin
  • Error importing SQL dump into MySQL: Unknown…
  • JSON Dump a string surrounded by single quotes and…
  • SMTP error 554
  • What are the undocumented features and limitations…
  • How to create Credential from service account key file?
  • useEffect Error: Minified React error #321 (GTM…
  • How to Update Database from Assets Folder in App
  • phpmyadmin.pma_table_uiprefs doesn't exist
  • XAMPP MySQL password setting (Can not enter in PHPMYADMIN)
  • Google Forms file upload complete example
  • Google drive get files with API-KEY
  • "Connection for controluser as defined in your…
  • How can I find the product GUID of an installed MSI setup?
  • Error # 1045 - Cannot Log in to MySQL server ->…
  • Direct download from Google Drive using Google Drive API
  • Error: the entity type requires a primary key
  • How do I include certain conditions in SQL Count
  • How can I fix MySQL error #1064?
  • Best way to do multi-row insert in Oracle?
  • ERROR 1698 (28000): Access denied for user…
  • Backbone.js model with validation for creating user…
  • Logging best practices
  • Select SQL Server database size
  • Google Colab: how to read data from my google drive?
  • Apache server keeps crashing, "caught SIGTERM,…
  • How to use the encrypt password for login php
  • Completely removing phpMyAdmin
  • Database development mistakes made by application developers
  • Should MySQL have its timezone set to UTC?
  • Persistent invalid graphics state error when using ggplot2
  • .Net How to create a Google Spreadsheet in Google Drive?
  • error: 'Can't connect to local MySQL server through…
  • How can I initialize a MySQL database with schema in…
  • How to update Python?
  • Vue2: Init data with other data value
  • How to connect to mysql with laravel?
  • Error message "Forbidden You don't have permission…
  • Use of Jquery on scroll event
  • Upload video files via PHP and save them in…
  • Polymer 1.0 Trying to make a splitter which works…
  • How do I install Java on Mac OSX allowing version switching?
  • How do you clear the SQL Server transaction log?
  • laravel vuejs/axios put request Formdata is empty
  • DJango doesn't execute request.method == "post" with…
  • Why cat does not work with parameter -0 in xargs?
  • Smart way to truncate long strings
  • Change the location of the ~ directory in a Windows…
  • javascript .replace and .trim not working in vuejs
  • SQL query return data from multiple tables
  • data.table vs dplyr: can one do something well the…
  • phpMyAdmin - can't connect - invalid setings - ever…
  • OpenIddict Roles/Policy returns 403 Forbidden
  • Installation of VB6 on Windows 7 / 8 / 10
  • Improve INSERT-per-second performance of SQLite
  • Why is php POST array empty for me in one instance…
  • How to embed a Google Drive folder in a website
  • phpmyadmin #1045 Cannot log in to the MySQL server.…
  • What are the best JVM settings for Eclipse?
  • Howto: Clean a mysql InnoDB storage engine?
  • Why does the 260 character path length limit exist…
  • Unable to open debugger port in IntelliJ
  • login form component in React
  • Start redis-server with config file
  • Android Studio: Database search functions fine but…
  • slim php get route with parameter (user login system)
  • How to find the mysql data directory from command…
  • How to display UTF-8 characters in phpMyAdmin?
  • php/mySQL on XAMPP: password for phpMyAdmin and…
  • SignInManager.SignInAsync doesn't sign me in (Vue.js SPA)
  • XAMPP - MySQL shutdown unexpectedly
  • Why Inserting a value in a nullable field from a…
  • Can Windows Containers be hosted on linux?
  • How to change the MySQL root account password on CentOS7?
  • ComboBox.SelectedItem giving Null value
  • issue which is related to vuex store + cookies
  • After the login click i am not able to render the…
  • java.sql.SQLException: - ORA-01000: maximum open…
  • What does "Could not find or load main class" mean?
  • Opening a CHM file produces: "navigation to the…
  • When validating, the location of the error on the…
  • Update array of objects depending on other array of…
  • Get multiple URL of attachments from a column in…
  • How to ping members from a string discord.py
  • How to create a new database after initally…
  • How do I count unique visitors to my site?
  • TypeError: Cannot read property 'webpackJsonp' of undefined
  • Backup database in Laravel 8
  • PHP - Failed to open stream : No such file or directory
  • How to store(bitmap image) and retrieve image from…
  • Android Studio - No JVM Installation found
  • Backbone.js Backbone.wrapError function

Disclaimer: This content is shared under creative common license cc-by-sa 3.0. It is generated from StackExchange Website Network.

Post navigation

Previous Post:

How do I push a new local branch to a remote Git repository and track it too?

Next Post:

Regular expression to match a line that doesn’t contain a word

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

.net ajax android angular arrays aurelia backbone.js bash c++ css dataframe ember-data ember.js excel git html ios java javascript jquery json laravel linux list mysql next.js node.js pandas php polymer polymer-1.0 python python-3.x r reactjs regex sql sql-server string svelte typescript vue-component vue.js vuejs2 vuetify.js

  • you shouldn’t need to use z-index
  • No column in target database, but getting “The schema update is terminating because data loss might occur”
  • Angular – expected call-signature: ‘changePassword’ to have a typedeftslint(typedef)
  • trying to implement NativeAdFactory imports deprecated method by default in flutter java project
  • What should I use to get an attribute out of my foreign table in Laravel?
© 2022 Fix Code Error