LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-28-2022, 11:17 AM   #1
seamore
Member
 
Registered: Sep 2009
Posts: 83

Rep: Reputation: 1
Importing sql into mysql error


I am importing a large text file with sql with the command:

mysql -u username -p database_name < file.sql

Processing stops at a particular line and says there is an error at line 461.

How can I have mysql print the line it could not process?
 
Old 04-28-2022, 11:31 AM   #2
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,249

Rep: Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323
Why wouldn't you just open file.sql in a text editor (preferably one that will show you syntax errors in MySQL files) and jump to line 461?
 
3 members found this post helpful.
Old 04-28-2022, 11:58 AM   #3
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,173
Blog Entries: 1

Rep: Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040
Quote:
Originally Posted by seamore View Post
I am importing a large text file with sql with the command:

mysql -u username -p database_name < file.sql

Processing stops at a particular line and says there is an error at line 461.

How can I have mysql print the line it could not process?
You can use:
Code:
sed -n 461p file.sql
 
2 members found this post helpful.
Old 04-28-2022, 12:53 PM   #4
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,880
Blog Entries: 1

Rep: Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871
or `cat -n file.sql | less -S` then type /461<Enter>
 
1 members found this post helpful.
Old 04-28-2022, 03:13 PM   #5
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,269
Blog Entries: 24

Rep: Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206
While I agree with others that acting on the error message and simply looking into the query source file is the most useful way to do that under most circumstances, you can have MySQL/MariaDB log all queries using MariaDB Audit Plugin and then grep the log file for failed queries which will include a distinct return code identifying those with errors.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] when importing modules from shell, no problem, but get errors importing in terminal window Deltac619 Linux - Newbie 3 03-04-2019 01:20 AM
FreeRadius: Failed to open file '/etc/freeradius/sql/mysql/schema.sql', error: 13 firewallengineer Linux - Networking 1 07-20-2016 02:43 PM
Imaging the running server and importing importing in vmware is possible ? winxlinx@gmail.com Linux - Virtualization and Cloud 2 06-27-2014 09:01 PM
[SOLVED] Importing an MS sql dbase into Mysql - linux linx win Debian 6 06-07-2010 03:53 AM
SQL: old sql dump not loading into new db BrianK Linux - Software 1 07-25-2006 11:55 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration