Software :: Update Csv File Into Mysql Db Via Bash Script?
Jan 12, 2010
I have a csv file that has a upc code and a qty (inventory). I need to insert it into my mysql table, but the table has several columns including upc, qty, price, etc. point me in the right direction to getting this done? Hopefully I can have a handy script when I'm done and all I do is run that script. I just want to make sure we don't delete the description, price, etc stuff and only update qty, using the upc code as the identifier so that the right qty get's input into the table.
how to update a file that is already exist in bash. so far i haven found any. I'm using parameter as my first start for the existent, copy file to a different directory.
I can't get mysql to update from lenny (mysql-5.0) to squeeze (5.1). apt tries to start the server but comes up with some kind of configuration script error.
I thought that the problem is in the phpMyAdmin not in the mysql. But now i think different. It seems that the problem is right in the mysql. I think that there was no root user, when mysql was freshly installed. Unfortunately i did everything i can find on internet (some tutorials) but they don`t helped me at all, maybe i fu**ed up the mysql service. So i reinstalled it, and when i want to start it there is no file mysql.sock and i get the following:
linux-nepg:~ # service mysql restart Restarting service MySQL Shutting down service MySQL done Starting service MySQL warning: /var/lib/mysql/mysql.sock didn't appear within 30 seconds
I need a bash script that can read from a MySQL database field and insert the read information into a variable. I need it to read from a field in the database which will list if somone is using Linux or Windows. Once its done that the code will continue as follows:
Code:
if [ "$var" = "linux" ] ; then OTHER CODE HERE else
I am not parsing on a webserver so is it possible to have both
#! /usr/bin/php & #!/bin/bash
in the same script? Alternatively, I have a current bash script that I need to get some variables from mysql and not sure how to get mysql results in bash:
Quote:
mysql -h server.net -u username1 -paaa -e "USE squid; SELECT email, usern FROM TABLE WHERE blah blah;" emailadd="resultfrom above" usern="resultfromabove"
I create a bash script that writes another bash file. But in the generated bash file I want to write a bash command in the file and not executing it.Here's my bash file:
Code: #!/bin/bash cat > ~/generateGridmix2data.sh << END
I need to know how to assign a result from a select. I am clueless on the sytax. I am trying this in bash. Maybe I am not assigning the array right. It gives me the whole row in the echo instead of just field a. How do I get fieldA = a in the select. Note script was stripped for security on database info but the syntax is same.
Code:
#!/bin/sh results="$(mysql --user ${DB_USER} -p${DB_PWD} ${DB_NAME} -Bse 'select a,b,c,d from tblMytable')" for rows in "${results[@]}" do fieldA=${rows[0]}; echo ${fieldA}; done
I am querying a single string column in a table. The string values have spaces in them. I want to loop over each value in bash. I set IFS to split lists on newlines instead of spaces. When I try this, it is splitting the list of results on the actual character 'n', not the newline ''.
DATA=`mysql -u root -ppassword --silent 'SELECT name FROM table_a;'` IFS=$' ' for i in $DATA; do echo "item = $i"
I just downloaded MySQL-Workbench and I see it in the folder: Code: /usr/bin how do I access it from my desktop without having to tie up my bash shell because the only way I can get to it right now is
Code: cd /usr/bin mysql-workbench
and only when I close the program can I use my bash for anything else.
I'm trying to get a password in a bash script for mysql user creation. But sometimes a get a non-alphanumeric character(s) in the password, and mysql failes with that. I tryed with apg -EO0Il1`~!@#$%^&*()_+-=[];./{}|:"'<>? but failed. I tryed with sed 's/[^a-zA-Z2-9]//g' , but at that moment the minimum password lenght failed. I'm also fine when there is a better alternative then apg.
I am attempting to write a backup script that will do the following:
1) lock and flush tables on a mysql db 2) dump the db to a file 3) unlock the tables 4) rsync the file to offsite storage
It all seems to be going well. However, obviously I don't want to setup ssh to the storage server on another network as the root user without a password. so I am attempting to su as the backup user inside of the script but when I try to run the script everything happens as it should until I try to so.. then it jumps out of the script .. akss me to login as the backup user.. proceeds to rsync to the offsite storage it does all this and then resumes execiting the script. it is not going to be setup as a cron job. it will be executed manually. assuming that is the case, how can I get the script to run without prompting for a password?
Here is what I've come up with so far... assuming that the script is run as root and the identity of the backup user will need to be assumed inside the script without perstering the user to enter the backup user's password.
I think this goes here, but I'm not sure. I decided that XAMPP had been troublesome enough. MySQL never worked. So I decided to instal the LAMP stack offered by YaST. I went about installing it thinking that it would all work. But it seems that I was wrong. So I try to start mysql, and here's what I get:
Code: the-matrix:~ # mysql start ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2) or Code: the-matrix:~ # rcmysql start Starting service MySQL warning: /var/mysql/mysql.sock didn't appear within 30 seconds chmod: cannot access `/var/run/mysql/mysqld.pid': No such file or directory
i am using liferay5.2(mysql included in the download pack) on fedora. while liferay is working fine but i cannot connect to mysql.i am getting the error
[ [root@localhost ~]# ln -s /var/lib/mysql/mysql.sock /tmp [root@localhost ~]# /etc/init.d/mysqld start Timeout error occurred trying to start MySQL Daemon.
[code]....
i didnt find the mysql.sock file in the location /var/lib/mysql/mysql.sock. i cannot find the portal-ext.properties file also to make intial settings.
I'm running OpenSuse 11.3 which comes with MySQL Workbench V 5.12.16-8.2. This version hangs on connections and has several other behavior problems that others have reported. For several reasons, I need 5.2+ . As a relatively new regular user of OpenSuse, I've learned that it's much better for me if I work within the package environment (read: I've made mistakes and am willing to learn) so I'm reluctant to try to just load the Suse rpm off the MySQL.org site. So:is there a more recent release of Workbench in a repository I've not found yet? if not, what's the safest way to install this as an rpm that will not impact the rest of the package management system?
i need to update my mysql database from 5.0 for 5.1, i have several java application and php application running on that server, without disturbing the setup i need to upgrade the server can someone suggest a method of doing this
I cant start mysql of my server after the update. my operating system is centos. I get this error. MySQL Daemon failed to start. Starting MySQL: [FAILED]
I wish to update a CentOS 5.6 system to PHP 5.3.8, but keep the MySQL version at 5.1.
I am using these repos (in addition to the stock CentOS repos):
epel rpmforge remi
At present, the system has php-5.3.5-1.el5.remi.1 and mysql-5.1.53-1.el5.remi.
When I attempt to 'yum update php' it automatically wants to update mysql to v5.5. If I explicitly exclude mysql either on the yum command line or in the remi repo config file, it produces depsolving errors.
Where may I find a set of PHP 5.3.8 RPMs which are NOT dependency bound to an upgrade of MySQL from v5.1?
I just ran some system updates today. MySQL was among them. after rebooting. I got a message I haven't seen since I was first installing several months ago. I couldn't connect to the database.
At first, I freaked out because I didn't know what to do. I tried checking my passwords, but I still don't understand all the configuration for MySQL. I tried reconfiguring the myth packages, but couldn't get through the setup. It would just bounce me out after a few attempts because of incorrect password sets.
I finally figured out, from the logs, that MySQL hadn't logged anything since it's 'successful shutdown' after the updates. It hadn't even tried to come on. I started it manually and everything seems to be fine, but how do I get it to start at startup again?
I'm having problems with my coding. Here is the problem: I have a database with a list of products. I can list all the products OK At the side of each product I have an EDIT and DELETE button. The delete button works fine and deletes the item. The EDIT button displays a form with all the details from the database. I can then edit this form and click on UPDATE. This is the code that I have to update the database:
I cannot see anything wrong with this code. But when I click on UPDATE (in the form), I get Error in executing UPDATE exhausts SET group = 'Alloy Silencers', description = 'RS 125 Aprilia', quantity = '1', price = '57.00', type = 'alloy', type2 = 'all', order = '', status = '1' WHERE id = '3' query
error: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 'group = 'Alloy Silencers', description = 'RS 125 Aprilia', quantity = '1', price' at line 1I have used this code many time before in other projects without problems.
After updating and installing Mysql's TOP, yum broke. When trying to clean, update, or install, the following error occurs:
dingle@its:/home/dingle# yum update There was a problem importing one of the Python modules required to run yum. The error leading to this problem was: No module named cElementTree Please install a package which provides this module, or verify that the module is installed correctly. It's possible that the above module doesn't match the current version of Python, which is: 2.4.3 (#1, Sep 3 2009, 15:37:12) [GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] If you cannot solve this problem yourself, please go to the yum faq at: [URL]
I tried to resolve by reinstalling the dependency, didn't work either: dingle@its:/home/dingle# rpm - [URL] Retrieving [URL] Preparing... ########################################### [100%] package python-elementtree-1.2.6-7.el4.rf.i386 (which is newer than python-elementtree-1.2.6-5.i386) is already installed
How can I rebuild YUM appropriately so it will operate correctly?
Code: The following packages will be upgraded: apache2 apache2-doc apache2-mpm-prefork apache2-utils apache2.2-common libcupsys2 libmysqlclient15-dev linux-libc-dev mysql-server mysql-server-5.0 php5-imap sudo 12 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 5 not fully installed or removed.
I'am using ubuntu lucid, after today's system updates, mysql stop working at all. Log file at /var/log/mysql/error.log does not say anything about today, and whe I try to start it the terminal hang also in verbose mode.
I'd like to use a perl script to update a fields in mysql database when pianobar (command line pandora radio player) starts a new song. Pianobar has the ability to run a script based on events, I'd like to take advantage of and use perl toparse the artist,song,album and update the corresponding fields. Then later retrieve them and display them with php/html. I am by no means proficient with perl. I started to use bash, but it looks like perl will be much more efficient and and less time consuming.
I am new to Linux and I wanted to setup a dedicated game server on my notebook.
I've installed Ubuntu 9.04. I than created a directory named /home/phlex/kfserver. I downloaded the application binary from Steam. I changed the file permission with chmod +x hldsupdatetool.bin and now the file attributes are -rwxr-xr-x.
The problem is when I try to run the binary file. If I type ./hldsupdatetool.bin I get an error message "-bash: ./hldsupdatetool.bin: No such file or directory. It seems the OS can't find the file. I've downloaded the file several times thinking it may have been corrupt but it's not. I can delete the file, I can rename it and so the file is there. Sometimes Linux can be aggravating to use.
I am supposed to take some small files, and print them to a specific printer, such that the small files are concatenated into one file. The file name has to be included in the file that gets printed.
Should I be looking to concatenate the files into one file with the file names included, and then print them?