I am trying to extract a certain table as csv using powershell, since this task is scheduled. Since using it in Powershell is basically the same I am showing you the commandline commands I tried using:
mysql --user=root --password=root apps_monitor -e "select * from board into outfile 'C:\Temp\export.text'"
And then I get the error:
The MySQL server is running with the --secure-file-priv option so it cannot execute this statement.
My question is how I disable this option. I tried editing the my-default.ini in the MySQL Server directory and adding
secure_file_priv=NULL
And
secure_file_priv=""
But both did not do anything upon restarting the mysql service. Can someone please help me with that thing.
Related
I have installed xampp in my macosx and i want to import the wordnet sql file its not working. i tried this command
/Applications/XAMPP/xamppfiles/bin/mysql -u root -p dict < wordnet20-from-prolog-all-3.mysql
The commandline works without any errors takes a while to finish.
I fireup phpmyadmin and check the dict database and nothing is there. What is the problem?
In your .sql file, look for a USE statement that would switch execution to another database. It might explain why you see nothing in the database used on the command line.
I am learning how to use mysql with Cloud9, I have a script used to create a default database and tables and loading sample data into the new database. How do I use the mysql-ctl tool to execute a script file?
It connects to a database just fine and I can execute ad-hoc queries without an issue.
You cannot use mysql-ctl to execute the script (you can see the source code running less $(which mysql-ctl) but you can use the usual mysql client command:
mysql -h 127.0.0.1 -u username < yourfile.sql
When you are in 'mysql-ctl' just run
source file_name.sql and your script will run.
I have a problem with a shell script:
I am trying to inject data from a source file containing MySQL queries into a data base. Here are the relevant lines of my shell script:
mysql -u root
source /usr/local/insert.sql;
quit;
For example I am running the file as ./insertfile and it is running smoothly but when it comes to data insertion in MySQL it is logging into MySQL using the mysql -u root command but the remaining operations (source /usr/local/insert.sql; and quit;) are not being executed. When I quit MySQL manually it tries to execute the rest of the command from my insert.sql file.
So please help me use the right shell script so that I can insert the queries from the source file.
One way to do that would be
mysql -u root --execute="source /usr/local/insert.sql; quit;"
It seems that your import hangs !
Check for lock on your database.
show processlist;
Run FLUSH TABLES to release any possible locks and then run your import command.
if source command hangs again :
Enter your myslq server
drop database insert;
create database insert
exit the mysql server and run:
mysqldump -u -p database-name < dump.sql
Thanks for your help. I have tried adding your line in my script and it was primarily giving some errors then I changed the command like below -
mysql -u root --execute="source /usr/local/insert.sql; \q"
Above line helped me to execute my command.
Thanks to all for being this much helpful.
Regards,
Shah9il
How can I import multiple files(.csv, .sql etc) into xampp mysql database ?
I am using Xampp and windows XP.
If I need to write command prompt type command, please tell in details where to find the command prompt type screen and so on.
The SQL files you can execute with MySQL command-line tool, e.g. -
shell> mysql db_name < script.sql
Load data from the CSV file into specified table you can with LOAD DATA INFILE statement.
If you do not have access to mysql client, then try dbForge Studio for MySQL. Free express edition allows to execute SQL scripts and import data from the CSV file without limitations.
This topic has been covered already, in its parts.
to import a CSV you can check this question, which will lead you to use:
LOAD DATA INFILE yourfile.csv
or if you need to update some data that is already on the database you can relate to a question I answered not long ago (and possibly other answers on stackoverflow).
You may execute this statement in the mysql prompt with mysql -u user -p -h localhost -D database (learn how to find the path to mysql.exe in your XAMMP using this question) or using some other way, such as your scripting/programming language of choice together with mysql connectors/libraries.
You may also use the mysqlimport.exe command (it'll be in the same folder as your mysql binary).
To import a sql file you can take a look at this question. You will essentially just copy the file contents into the mysql prompt, which is usually done with input redirection on the console:
C:>mysql -u user -p -h localhost -D database -o < yoursqlfile.sql
I hope that besides answering your question i might also have introduced you to the fact that with thousands(?) of questions in stackoverflow you are very likely to find the answers to your doubts by searching the questions database, possibly faster than asking your own new question.
I created a data base using mysql. I used MySQLDump to create one database backup file in text format (MySql 5.5 on Windows XP). The database is local on my machine (local host).
I am having trouble using the MySQL command to load the dump file to restore the database. I have done the following:
Research stack overflow for how to do it. I noticed there's a bug using the MySQL command to restore the data from a post. Before I run the command, I DROP the database and CREATE the database using MySQL workbench.
I type the following command in the DOS prompt to restore the database:
mysql -u root -p -h localhost -D matlab_data -o < backup.sql
backup.sql is a the backup file in text format created by MySqlDump.
I am then asked for the password which I enter. I get the DOS prompt right away with no error message. I've waited several hours for the command to run and the database is still empty.
I have tried various command formats over the last few days. If I enter incorrect data in the command line (non existen file, database, etc), I get an error message.
I feel I would not see the DOS prompt until the database is restored. If I don't DROP and CREATE the database, I get an error message. Otherwise, not.
Does anybody have any idea what the issue is? I realize that I could be making a stupid mistake.
Thank you for your help.
shell into the mysql console and run the sql file as this
If you are already running mysql, you can execute an SQL script file using the source command or . command:
mysql> source file_name
mysql> \. file_name
note that file_name must be an absolut path