How To Execute A Query From A File In OS X Leopard
I want to execute a query from within a file in OS X Leopard. The syntax (according to what I could find on the web) should be:
mysql> . /Users/peterv/bin/test.sql;
but it gives me this error:
ERROR:
Failed to open file '/Users/peterv/bin/test.sql;', error: 2
The file has the correct permissions.
View Complete Forum Thread with Replies
Related Forum Messages:
Execute A File
Is there a way to execute an SQL script from a file on disk from within MySQL? For example, I have a file containing a valid SQL script at C:david.sql. From within MySQL, I would like to dynamically execute the script contained within that file. Does there exist the syntax to do the equivalent of EXECUTE C:david.sql? I know I can make david.sql a stored procedure … and then CALL david(). I’ve done that. However, frank.sql happens to contain a CREATE FUNCTION statement, and MySQL won’t let you embed a CREATE FUNCTION statement within a stored procedure. If there’s another way to accomplish that end
View Replies !
Execute A Script File
I just update mysql server to version 4.1. And I try to use the following command: source C:/Program Files/MySQL/ MySQL Server4.1/data/wormlibrary/table_image.txt to execute a sql script file, but always get error like can't create table....(errno:150) This command and script file worked fine when I use version 4.0
View Replies !
Cant Execute Batch File
Hi new to this but pulled out nearly all my hair with this. I got the test database open and I want to automate creating the menagerie table ( as in the tutorial ) so I download the textfile save it to c:/ and execute the command source c:/cr_pets_tbl.txt all I get is unable to open file error 22. I have tried creating my own text file ( windows, notepad ) just containing the following use test; create table pets(name varchar(10),species varchar(8),born date); simple as that then type in the consoe source c:/pets.txt; unable to open file error 22 or sometimes error 2 tried enclosing filename in " and ' tried source= filename tried . instead of source but nothing works. using manual insert command or load data local infile works but not this, HELP. Malcolm K.
View Replies !
How To Execute A Batch Sql File Under Windows?
I have installed MySQL 5 in c:Program FilesMysql. I have a sql file named "books.sql" which is put in the subfolder in,it contains many statements that like "INSERT ... value ...". my question is how to execute it? I try it, but failed. One more question is how can I return from "->" to "sql>" promopt?
View Replies !
Execute Time Of A Query
I'm running a SELECT * query on a table with over 3,000 rows. I need to know the execute time on the query. PHPMyAdmin shows it to me, but because they automatically add a LIMIT 0, 30 I suspect the time is only for those 30 records. It also has a feature to prevent web server timeouts that prevents me from setting the LIMIT to 0, 3100. BTW, I'm programming in PHP. Does the time to run the query get automatically passed when PHP sends the query to MySQL? <? PHP $Query = "select * from my_table where 1"; $Result = MYSQL_QUERY($Query); ?>
View Replies !
Average Query Execute Time???
I have a query taking about 4 sec that gets only 18 records.. That's not good. What can I do to speen up my Query? <CFQUERY DATASOURCE="#datasource#" NAME="qry_job_search"> SELECT DISTINCT (t1.JobPostId), t1.Actionlkp, t1.Date, tbl_job_posting.*, tbl_job_post_requirements.*, tbl_employer_info.*, tbl_employer_url.*, tblkp_employment_type.*, tblkp_education_exp_lvl.*, tblkp_salary_range.*, tblkp_employment_exp_lvl.*, tbl_job_post_location.*, tbl_job_post_job_categories.JobCat, tblkp_countries.*, tblkp_prefectures.* FROM tbl_job_post_history AS t1 JOIN tbl_job_post_location ON tbl_job_post_location.JobPostID = t1.JobPostID JOIN tblkp_countries ON tbl_job_post_location.CC1 = tblkp_countries.CC1 JOIN tblkp_prefectures ON tbl_job_post_location.CC1 = tblkp_prefectures.CC1 AND tbl_job_post_location.PrefectureID = tblkp_prefectures.ADM1 LEFT JOIN tbl_job_post_requirements ON tbl_job_post_requirements.JobPostID = t1.JobPostID LEFT OUTER JOIN tbl_job_post_job_categories ON tbl_job_post_job_categories.JobPostID = t1.JobPostID JOIN tbl_job_posting ON tbl_job_posting.JobPostID = t1.JobPostID JOIN tbl_employer_info ON tbl_employer_info.UserID = tbl_job_posting.UserID LEFT JOIN tbl_employer_url ON tbl_employer_url.EmployerID = tbl_employer_info.EmployerID JOIN tblkp_employment_type ON tblkp_employment_type.ID = tbl_job_posting.EmploymentType JOIN tblkp_education_exp_lvl ON tblkp_education_exp_lvl.ID = tbl_job_posting.EducationExpType JOIN tblkp_salary_range ON tblkp_salary_range.ID = tbl_job_posting.Salarylkp JOIN tblkp_employment_exp_lvl ON tblkp_employment_exp_lvl.ID = tbl_job_posting.EmploymentExpType WHERE t1.JobPostId NOT IN ( SELECT DISTINCT (JobPostId) FROM tbl_job_post_history WHERE Actionlkp =4 AND date = ( SELECT MAX( date ) FROM tbl_job_post_history WHERE JobPostId = t1.JobPostId ) AND JobPostID = t1.JobPostID ) AND HistID = ( SELECT MAX( HistID ) FROM tbl_job_post_history WHERE JobPostID = t1.JobPostId AND Actionlkp =1 ) AND Date >= ( curdate( ) - INTERVAL 30 DAY ) <CFIF SESSION.COUNTRY_A NEQ "" AND SESSION.PREFECTURE_A EQ 0 AND SESSION.CITY_A EQ ""> AND tbl_job_post_location.CC1 = '#SESSION.COUNTRY_A#' <CFELSEIF (SESSION.COUNTRY_A NEQ "" AND SESSION.PREFECTURE_A NEQ 0 AND SESSION.CITY_A EQ "") OR FORM.PREFECTURE NEQ 0> AND tbl_job_post_location.CC1 = '#SESSION.COUNTRY_A#' AND tbl_job_post_location.PrefectureID = '#SESSION.PREFECTURE_A#' <CFELSEIF SESSION.COUNTRY_A NEQ "" AND SESSION.PREFECTURE_A NEQ 0 AND SESSION.CITY_A NEQ ""> AND tbl_job_post_location.CC1 = '#SESSION.COUNTRY_A#' AND tbl_job_post_location.PrefectureID = '#SESSION.PREFECTURE_A#' AND tbl_job_post_location.PostCity LIKE '%#SESSION.CITY_A#%' </CFIF> <CFIF (SESSION.CATEGORY_A NEQ 1) OR FORM.CATEGORY NEQ ""> AND tbl_job_post_job_categories.JobCat = '#SESSION.CATEGORY_A#' </CFIF> <CFIF (SESSION.KEYWORD NEQ "") OR FORM.KEYWORD NEQ ""> AND t1.Actionlkp = 1 AND (tbl_job_posting.JobTitle LIKE '%#session.Keyword#%' OR tbl_job_posting.JobDescription LIKE '%#session.Keyword#%' OR tbl_job_post_requirements.JobRequirements LIKE '%#session.Keyword#%') <CFIF SESSION.KEYWORD NEQ "" AND SESSION.PGV NEQ "brief"> <CFSET SESSION.PGV = "detailed"> </CFIF> </CFIF> <CFIF SESSION.EMP_TYPE_A NEQ 1> AND tbl_job_posting.EmploymentType = '#SESSION.EMP_TYPE_A#' </CFIF> <CFIF SESSION.EXP_LVL_A NEQ 1> AND tbl_job_posting.EmploymentExpType = '#SESSION.EXP_LVL_A#' </CFIF> <CFIF session.SRT EQ "D"> ORDER BY Date DESC <CFELSEIF session.SRT EQ "C"> ORDER BY tbl_employer_info.CompanyName <CFELSEIF session.SRT EQ "L"> <CFIF form.country NEQ 0> <CFIF form.prefecture NEQ 0> <CFIF form.city NEQ 0> ORDER BY tbl_job_post_location.PostCity </CFIF> <CFELSE> ORDER BY tblkp_prefectures.FullNameS, tbl_job_post_location.PostCity </CFIF> <CFELSE> ORDER BY tblkp_countries.CC1, tblkp_prefectures.FullNameS, tbl_job_post_location.PostCity </CFIF> <CFELSEIF session.SRT EQ "T"> ORDER BY tbl_job_posting.JobTitle </CFIF> </CFQUERY> Can anybody see a shortcut to get the same results??
View Replies !
Couldn't Execute '/*!40100 SET @@SQL_MODE='' */': Query Was Empty (1065)
I upgraded to MySQL 5.0, but the remote server still runs 3.23. Before I upgraded I was able to, in a local DOS-prompt, execute a mysqldump and get the database from the server to a file on my computer. Now, when I execute the same query, the remote server does not understand my command. This is what I execute on my local computer (simplified): C:foldermysqldump --add-locks --add-drop-table -h xx.xx.xxx.xx -u username -p database > "C:folderdb_downloaded.sql" This used to work, but after I upgraded I get the error message: Couldn't execute '/*!40100 SET @@SQL_MODE='' */': Query was empty (1065)
View Replies !
On Leopard
I have a development server that is an OS X 10.5.2 box. MySQL is started. I cannot access MySQL with phpMyAdmin even though I have defined the root mysql password in Server Administrator Also, I cannot access mysql from the command line. error message from command line is "Access denied for user 'root'@'localhost' (using password:YES)
View Replies !
Installation Help For Mac OS X 10.5 Leopard
I am trying to install MySQL for my Mac running OS X 10.5 Leopard. I want to use a GUI to avoid scrambling something in Terminal, as well as it being easier on the eyes. I have downloaded the two DMG's: mysql-5.0.67-osx10.5-x86.dmg mysql-gui-tools-5.0-r12-osx10.4-universal.dmg I installed the GUI no problem, but MySQL is another thing. I have been scouring the internet for a month or so looking for a definitive way to install it, and there doesn't seem to be one. I tried following some directions a few weeks ago, but I must have messed up. Is it as easy as just installing the packages in the dmg, as well as the prefpane? Or do I need to do some Terminal work as well?
View Replies !
Installing MySQL 5.0.24 On Leopard
I'm trying to install MySQL 5.0.24 on Leopard. I've downloaded the package - version Mac OS X 10.4 (x86): http://dev.mysql.com/downloads/mysql/5.0.html#macosx-dmg - and installed it with the wizard. The installation was successful, but the directory /usr/local was not created. The reference manual (http://dev.mysql.com/doc/refman/5.0/en/mac-os-x-installation.html): "The Mac OS X PKG of MySQL installs itself into /usr/local/mysql-VERSION and also installs a symbolic link, /usr/local/mysql, that points to the new location." What am I doing wrong?
View Replies !
Cannot Seem To Connect To MySQL Mac OS Leopard
I've been working all day at getting MySQL and Ruby installed and running in my system and it has been one headache after the next. Finally I am at a point where I should be able to login to MySQL to create a database, but this is what is happening. /usr/local/mysql/bin/mysqladmin create database --user=root -p Enter password: /usr/local/mysql/bin/mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: YES)' I have installed the MySQL system preferences pane and it tells me that MySQL IS running. Also, for some reason if I tell it to drop a database that I recently tried creating, it warns me that dropping it will destroy all data, but when I say to proceed, it again says access denied. If it was denying me access to create a database initially, wouldnt it have said "database not found" rather than warn me about destroying it?
View Replies !
Stopped Working (Leopard 10.5.6)
the issue is that at some point between last Friday and yesterday, my server stopped working. I tried checking the mysql.sock, but its still there. I can still connect through the Terminal by running the bin mysql, but navicat and java can't connect. EDIT: PHP seems to be working and navicat starts working if i select "connect through mysql.sock", but java says "Host is down" which is not.
View Replies !
MySQL Install On Leopard
I have upgraded from Tiger to Leopard (10.5.1) and am trying to get MySQL to work. Now many of you will say I shouldn't have upgraded and maybe so (however, I do have a backup Tiger machine if need be). Problem is the following error: Warning: mysql_pconnect() [function.mysql-pconnect]: Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' I have used terminal commands to copy the "mysql.sock" file to the directory but to now avail. Since the mysql installation was present and working before the upgrade and since this machine is operating for webserver sharing I would like to get it working if possible. As well I do have a database backup so we're good there. I'm willing to start over with MySQL (uninstall, re-install) but can't find proper instructions for Leopard on how to do so even after searching for a few long hours.
View Replies !
Setting Up MySQL On Mac > Leopard
PHP Code: $link = mysql_connect ("localhost" , "Cretaceous" , "Dinosauria") or die(mysql_error());mysql_select_db ("Trex", $link) or die(mysql_error()); and put it on a test page. When I preview it in a browser, it gives me the following error message: Code: Access denied for user 'Cretaceous'@'localhost' (using password: YES) I checked the privileges, as follows: User (Cretaceous), Host (%), Password (Yes), Global privileges (USAGE), Grant (No) It looks like my user name and password are OK. I changed the database name from Trex to trex (all lower case), but I get the same error message. Since the Privileges page lists the Host as %, rather than localhost, do I have to make some sort of change there? I replaced "localhost" with % in my database query but that doesn't work.
View Replies !
DBD::mysql::st Execute Failed: Lost Connection To MySQL Server During Query
I am using perl to connect to a database and then pull the rows off of the table one by one to manipulate the data. If I use a smaller table (~8 MB), I wait for around 20 seconds but then the table values are read just fine. However if I use a larger table (~30 MB), I wait for a while and then I get the message: DBD::mysql::st execute failed: Lost connection to MySQL server during query I have tried searching for the solution to this problem and haven't found anything that helps yet. I have changed the values of 'max_allowed_packet' and 'wait_timeout', with no effect. Any ideas?
View Replies !
Run Query From A File
I tried: mysql> source 'file_name'; and mysql> . 'file_name' right now I'm running version 4.0.something on WinXP and I repeatedly get the following error: Failed to open file 'file_name', error: 2 Any ideas?
View Replies !
Query To Retrive File Names
Lets consider: table1 col1 "sometext /a.jpg sometext /b.jpg sometext /c.jpg sometext..." "sometextt2 /d.jpg sometextt /e.jpg sometextt /f.jpg sometextt..." etc... This query: SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(col1,'.jpg', 1),'/', -1) from table1; returns only file names: a d but b(.jpg) , c(.jpg), e(.jpg) and f(.jpg) are not returned! My desired result should look like this: a b c d e f any suggestions about how to get all the other file names ?
View Replies !
No Digits Output/query > File ? > Spreadsheet?
Two questions: My query works fine but I need two things: a) How can I limit the number of digits outputed? I cannot find anything in my.cnf that seems to deal with this. I would like to limit the output to one digit past the decimal point ( a computation this field - that field). b) Getting the answer to my >select etc is just the first stage! I would like the answer to end up in a spreadsheet. mysql>select etc > /my/path/to/my file gives me an error message. I know in the command line output can be outputted to a file. Can the same thing be done in the mysql> command line? How? or what is the #command line command eg mysql select etc?
View Replies !
Query To Search And Retrieve File For Download
I am new to web development and have this challenge. I want to design a dynamic website for a college community using PHP and MYSQL. The objective of the site is to hold the annual report of all the departments such that visitors can select the desired department and the year of the report. The years could stretch back to as long as the college existed but I want to limit the backdate to 10 years for now. The visitor should be able to select a department and desired year, view the report online and also be able to download the same report stored in a directory in ms word or PDF format. What should the table structure look like? Also the PHP and SQL script to search for the stored files and make them available for download.
View Replies !
EXECUTE Sp_rename
Hi, im coverting a mssql 2000 databse to mysql and ive good to a road block, that i cant seem to figure out how to get round. Part of the MSSQL 2000 code is Code: EXECUTE sp_rename And i cant seem to find an equivelant for mysql, i wa wondering if anybody knows of a way to get around this? All help is greatly appreciated Thanks Again Andy
View Replies !
How To Execute A SQL Script
I have successfully installed MySQL 5 and can also connect to the server. The issue is that my developer has sent me a copy of the database in .sql fromat (filename: abc.sql) and I do not know how to execute it so I can extract the tables. Can someone please show me the way?
View Replies !
Execute More Then One Sql Statement
In MSDE I could do this "insert into tbl set fld = 1; insert into tbl set fld = 2". When I try that in MySQl, I get an error (below). You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '; insert into tbl set fld = 2' at line 1 Does MySQl not support this?
View Replies !
Execute Scripts From VB.Net
I want to build a VB.NET update package for an application. So with each new release I want to update the client's database. I work with Stored Procedures, so in order to update the newest sp, I want to run a sql script from VB.NET on the client's pc. It is easy to run normal non-queries, but how do I execute a script?
View Replies !
Execute Trigger
i have created a procedure which generates a trigger on passing the table name to the procedure. now i want to execute this trigger which is currently stored in a user variable in the stored procedure. how do i execute the trigger directly from the procedure only or the procedure user variable.
View Replies !
Incorrect Arguments To Execute
i am using the development release of mysql and have a PROCEDURE that executes a prepared statement. it works fine when i call the procedure but repeating it multiple times produces an "incorrect arguments to execute" error. replacing the prepared statement with a normal statement eliminates the error. is this due to the release or is a prepared statement not allowed in the procedure? i read somewhere that procedures are precompiled and hence will it be as fast as calling it multiple times without using the prepared statement?
View Replies !
Execute A Script In MySQL
I am renting space on 2 servers. On one server I created a script with sql's "create table .., insert into...". Now I want to execute this script on the second server. What is a syntax? I tried from telnet: dbname < file.sql where dbname is a name of my db and file.sql is a script, but I got message "syntax error".
View Replies !
Can't Execute Delete With The IN Operator
Lately I have been started using MySQL. I managed to create my database and tables. When I wanted to execute the following query: delete from adminpages where parentid IN ( select DISTINCT A.id from adminpages AS A where A.name='galeries' ); I have received the following error message: Error Code : 1064 You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'select DISTINCT A.id from adminpages AS A where A.name='galeries' (0 ms taken).
View Replies !
Execute Mysqldump Command
I have a file containing the mysqldump command looks like this: mysqldump -t CPS_Trans Transactions --where:"(TerminalId = 06670002 and ..... I want to know how I can execute that file so that I can output th result to a another text file.
View Replies !
Execute Batch Mode
I want to execute the queries wriiten in a .sql file in a single attempt using the batch process of mysql.Since I don't have a good grip over the database systems, I am confused how should I go for it..
View Replies !
Execute Script Blocks
Is there any way that I can get code like this to run directly in the MySQL command line client (or similar tool) without using a wrapper proc/function? DELIMITER $$ BEGIN -- Example block of script code that uses an IF statement IF (1 + 1 = 2) THEN SELECT 'True' AS Message; END IF; END $$ I often want to execute script blocks directly during development when testing out code.
View Replies !
Statement Execute Failed
I am trying to store a binary image into a blob field and I am getting the following error: DBD::mysql::st execute failed: MySQL server has gone away at ...(file and line number here). I am following several online tutorials on the subject and each one (different implementations) fail at the execute line. If someone could tell me how to fix this I would greatly appreciate it. I have already tried commenting out the dbh->disconnect; line and it had no effect. Here is the code that is failing. use DBI; our $dbh = DBI->connect('DBI:mysql:pic_test:localhost','whateveruser','whateverpassword', {RaiseError => 1 }); my $sth = $dbh->prepare("INSERT INTO tbl_files (ImageColumn) VALUES (?)"); open(my $fh, 'input.jpg') or die $!; read( $fh, $var, -s $fh ); $sth->execute($var); $sth->finish; $dbh->disconnect; I am using MySQL server 5.0 on Windows XP and Active PERL 5.8.8.
View Replies !
Execute Script Daily?
I have a database set up as a membership directory. We would like to get an email if a member has not paid his/her dues in a year. Is it possible to set up something in mysql for it to check the database daily for people who's dues haven't been paid in a year and then execute a script that sends me an email with the names of those people? I know I could write a php script to do it, but it just needs to be executed automatically each day so i'm not sure how to make it happen.
View Replies !
|