Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Programming/Scripts

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Thread Tools Display Modes
Old 1st April 2006, 00:48
edge edge is online now
Join Date: Dec 2005
Location: The Netherlands
Posts: 2,044
Thanks: 269
Thanked 154 Times in 133 Posts
Default Bash - reading stuff from MySQL..

Hi all,

I could really use some help with some bash coding, and reading stuff from a database.

Lets say that the owner of the DB is named: root
His password is: 12345
The name of the MySql databaes it: somename
The server is: localhost

The quiry to create the database looks like this:
CREATE TABLE `name_users` (
  `ID` int(10) NOT NULL auto_increment,
  `user_name` varchar(50) default NULL,
  `user_emailaddress` varchar(50) default NULL,
  `user_info` varchar(50) default NULL,

Now how do I read the database named 'somename', read the table 'named_users' and show only the results of 'user_name' and 'user_info' (like this)

frank		some user info about frank here
peter		some user info about peter here
steven		some user info about steven here
This all needs to be dumped in a 'txt' file.

Anyone here who could give me some help / samples with this?
Reply With Quote
Sponsored Links
Old 1st April 2006, 04:17
sbovisjb1 sbovisjb1 is offline
Senior Member
Join Date: Feb 2006
Posts: 176
Thanks: 0
Thanked 1 Time in 1 Post
Default Simple I/O

Here is the MySQL documentation- http://dev.mysql.com/doc/refman/5.0/...ad-states.html.
Understandibly its a little confusing, so when ever i need to look at I/O I ALWAYS look at C++. (Cpluscplus is good) and here is a good article http://www.devshed.com/c/a/MySQL/SQL...onsiderations/
Reply With Quote
Old 1st April 2006, 12:55
falko falko is offline
Super Moderator
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,749 Times in 2,579 Posts

If you want to do this from a shell script, have a look at the mysql command:
man mysql
There's an option (-e) that lets you execute MySQL queries directly from the shell.
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
Old 4th April 2006, 15:49
22hosting 22hosting is offline
Junior Member
Join Date: Apr 2006
Posts: 26
Thanks: 0
Thanked 1 Time in 1 Post

mysql -e SELECT user_name, user_info FROM named_users -u <mysqlusername> -p <mysqlpassword> somename

or something like that
Stage Grinder

Last edited by 22hosting; 22nd August 2011 at 13:59.
Reply With Quote


Thread Tools
Display Modes

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
postfix - MySQL connection problem epo Installation/Configuration 7 4th August 2006 21:49
MySQL installation roblem [/me sad] Nejko Installation/Configuration 16 11th January 2006 14:28
Mandriva 10.2 Perfect Setup Install Problems... ctroyp Installation/Configuration 12 30th December 2005 17:04
Problem installing ISPConfig, then with MySQL... ctroyp Installation/Configuration 7 26th September 2005 17:37
MySQL issue during install of ISPConfig ricbax Installation/Configuration 4 16th September 2005 10:41

All times are GMT +2. The time now is 20:23.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.