LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-21-2002, 04:02 AM   #1
richard22
Member
 
Registered: Apr 2001
Posts: 60

Rep: Reputation: 15
mysql script files


I'm starting to play around with mysql. I can run a script file - say a_script_file.sql in the sql directory in my home directory from the bash command line by invoking:
mysql -u username -p database_name < sql/a_script_file.sql
It works after inputing password at the prompt.
However from the mysql prompt, when connected to the database, I run:
database_name < sql/a_script_file.sql;
I receive an error message "You have an error in your SQL syntax 'database_name < sql/a_script_file.sql' at line 1.
I can't figure out what that syntax error might be, can anyone help.

Regards Richard
 
Old 08-16-2005, 03:20 AM   #2
dobriain
LQ Newbie
 
Registered: May 2002
Location: Ireland
Distribution: SuSE
Posts: 14

Rep: Reputation: 0
Within your SQL script file you probally have a create database type command:

How did you create the script file ?? with the mysqldump command ??

If so the script file will have lines like:

CREATE DATABASE /*!32312 IF NOT EXISTS*/ `MyDB` /*!40100 DEFAULT CHARACTER SET latin1 */;

Restore the script file like this:

linux:~ # mysql -uroot -ppassword < script_file.sql

Now recreate users for the database(s) with GRANT options.

linux:~ # mysql -uroot -ppassword

mysql> grant all on MyDB.* to 'MyUser'@'localhost' identified by 'MyPass' with grant option;

mysql> SHOW GRANTS for 'MyUser'@'localhost';
+--------------------------------------------------------------------------------------------------------------+
| Grants for MyUser@localhost |
+--------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'MyUser'@'localhost' IDENTIFIED BY PASSWORD '*A1361C38B5A8A0E651E9D019408FAB7F32F600A8' |
| GRANT ALL PRIVILEGES ON `MyDB`.* TO 'MyUser'@'localhost' WITH GRANT OPTION
+--------------------------------------------------------------------------------------------------------------+
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Mysql script petenyce Linux - Newbie 2 11-22-2005 12:30 PM
MySQL restart script? Fuwex Debian 2 08-17-2005 02:23 PM
Connect to mysql through script newuser455 General 8 03-25-2005 10:23 PM
Mysql in bash script acrors Red Hat 2 08-18-2004 09:11 PM
Bash script and mysql flashingcurser Programming 1 07-19-2004 03:35 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:06 AM.

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