NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Webmaster Tutorials
Reload this Page HOW TO: Use shell to control MySQL.

Webmaster Tutorials Instructional webmaster-related how-to's and tutorials.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 07-23-2005, 09:54 PM THREAD STARTER               #1 (permalink)
Account Closed
 
abdulmueid's Avatar
Join Date: Jun 2005
Location: Mozambique
Posts: 607
abdulmueid has a spectacular aura aboutabdulmueid has a spectacular aura about
 



HOW TO: Use shell to control MySQL.


Some people have a shell account with hosting but dont have a clue on how to put it to some good use. Shell Account or SSH can save alot of time if used properly.

I will show how to do some of the most common tasks easily and faster in shell.

First of all you will need a ssh client to connect to the remote server. I use PuTTY to access my shell accounts but you can use anyone that you like, there are plenty available.

Use your domain-name as your hostname and login. Enter username and password when required.
Once you are logged in you will see: "username@localhost$" or something similar.
at this point type:
Quote:
cd public_html
You can replace public_html with your web-folder if it is not public_html.
????: NamePros.com http://www.namepros.com/webmaster-tutorials/109303-how-to-use-shell-control-mysql.html

You can move around different folders using CD command just like Ms-Dos prompt. Remember instead of "cd.." for moving to the previous folder, you will have to type "cd .." space between cd and ..

Starting MySQL:
type:
Quote:
mysql -u username -p
Replace "username" with your database username. This works wherever database hostname is "localhost".
If your database server is located somewhere else then type:
Quote:
mysql -h hostname -u username -p
Replace "username" with your database username.Replace "hostname" with your database server's hostname. i.e. db.somedomain.com.

After typing the command, hit enter. It will now ask for the the password associated with that username. Enter password and hit enter.

Now you will see "mysql>" instead of "username@localhost:>". This means we have successfully logged in to Mysql.

Selecting Database to use:
At mysql> type:
Quote:
use databasename
Replace "databasename" with the name of the database that you want to work on. Hit Enter

Adding a new Database:
At mysql> type:
Quote:
create database databasename;
Replace "databasename" with the name of the database that you want to create. Hit Enter

Deleting a Database:
At mysql> type:
Quote:
drop database databasename;
Replace "databasename" with the name of the database that you want to delete. Hit Enter

Creating Tables:
At mysql> type:
Quote:
create table tablename;
Replace "tablename" with the name of the table that you want to create. Hit Enter

Deleting Tables:
At mysql> type:
Quote:
drop table tablename;
Replace "tablename" with the name of the table that you want to delete. Hit Enter

Exiting MySQL:
Simply type:
Quote:
exit
and hit enter.
????: NamePros.com http://www.namepros.com/showthread.php?t=109303

Now you are back to shell prompt.

Backing up your database:
At normal shell (Not mysql>) type:
Quote:
mysqldump --add-drop-table -h databasehostname -u databaseusername -p databasename | bzip2 -c > blog.bak.sql.bz2
Replace databasehostname with your database host (if it is localhost then you can remove "-h databasehostname"), replace databaseusername with your database username and replace databasename with the name of database that you want to backup.
Hit enter, it will ask you for your database password. Enter the password and hit enter.
All done. This will output a file "blog.bak.sql.bz2" in the folder you were working in (public_html).
NOTE: I am using blog as an example for the output file. You can name it as you feel like, just dont change .sql.bz2 extention. i.e. forum.bak.sql.bz2 or forum.sql.bz2...

Restoring the database:
The database that we created in previous step is compressed in order to give us a small file. To restore the database we first need to uncompress the database.
Supposing that you are in the same folder as the compressed file.Type:
Quote:
bzip2 -d blog.bak.sql.bz2
You can change "blog.bak.sql.bz2" to the filename that you used when creating the backup.

Now type:
Quote:
mysql -h databasehostname -u databaseusername -p databasename < blog.bak.sql
Replace databasehostname with your database name (you can remove "-h databasehostname" if your database server is localhost), Replace databaseusername with your database username and Replace databasename with the name of the database to which you want to restore the backup file.

Hit Enter, it will ask for your database password, type it and hit enter. VOILA! Your database is restored.

Using shell may look tedious and hard at first but once you get hold of it, you will feel "more at home" with it than any other control panel.

Hope this help those people with shell account but did not know how to use it.

MODS: If you like the topic and think it is useful then please sticky it. Thank You
Last edited by abdulmueid; 07-31-2005 at 04:11 AM.
abdulmueid is offline  
Old 07-24-2005, 02:17 PM   #2 (permalink)
NamePros Regular
 
Masahiro's Avatar
Join Date: Jul 2005
Location: South Devon, United Kingdom
Posts: 955
Masahiro is just really niceMasahiro is just really niceMasahiro is just really niceMasahiro is just really nice
 



Nice tutorial, thanks for that!
Masahiro is offline  
Old 07-24-2005, 03:03 PM THREAD STARTER               #3 (permalink)
Account Closed
 
abdulmueid's Avatar
Join Date: Jun 2005
Location: Mozambique
Posts: 607
abdulmueid has a spectacular aura aboutabdulmueid has a spectacular aura about
 



You are welcome
abdulmueid is offline  
Old 07-24-2005, 09:50 PM   #4 (permalink)
Senior Member
 
nomis135's Avatar
Join Date: Mar 2005
Location: Quebec, Canada
Posts: 2,023
nomis135 is a name known to allnomis135 is a name known to allnomis135 is a name known to allnomis135 is a name known to allnomis135 is a name known to allnomis135 is a name known to allnomis135 is a name known to allnomis135 is a name known to all
 



oh thanks a lot i needed to find tutorials about shell access as i don't completly know how to use it.

I know basic commands such as top or netstat.
nomis135 is offline  
Old 07-25-2005, 07:28 AM THREAD STARTER               #5 (permalink)
Account Closed
 
abdulmueid's Avatar
Join Date: Jun 2005
Location: Mozambique
Posts: 607
abdulmueid has a spectacular aura aboutabdulmueid has a spectacular aura about
 



I will be posting more on Shells since I used to be a "junior" admin myself some time ago, so i know quite alot about it and have working experience.


P.S. My current host likes being old skool and has no cPanel. All site management has to be done via Shell
abdulmueid is offline  
Old 07-25-2005, 08:31 AM   #6 (permalink)
Senior Member
Join Date: May 2005
Location: Ontario Canada
Posts: 3,088
unknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to behold
 


Diabetes
Nice tutorial really helpful for a newbie like myself

+1 rep added
unknowngiver is offline  
Old 07-25-2005, 09:00 AM   #7 (permalink)
Senior Member
 
nomis135's Avatar
Join Date: Mar 2005
Location: Quebec, Canada
Posts: 2,023
nomis135 is a name known to allnomis135 is a name known to allnomis135 is a name known to allnomis135 is a name known to allnomis135 is a name known to allnomis135 is a name known to allnomis135 is a name known to allnomis135 is a name known to all
 



Originally Posted by abdulmueid
I will be posting more on Shells since I used to be a "junior" admin myself some time ago, so i know quite alot about it and have working experience.


P.S. My current host likes being old skool and has no cPanel. All site management has to be done via Shell
That must be a pain but at least you learn shell and i doubt you'll forget
nomis135 is offline  
Old 07-25-2005, 10:43 AM THREAD STARTER               #8 (permalink)
Account Closed
 
abdulmueid's Avatar
Join Date: Jun 2005
Location: Mozambique
Posts: 607
abdulmueid has a spectacular aura aboutabdulmueid has a spectacular aura about
 



It was pain in the beginning, I mean I got the hosting in 2003 and still have it. Been using it all that time. It was/is my first hosting ever, when I got hosted there i had never even heard about cPanel. Only way to survive was to learn and I did it
abdulmueid is offline  
Old 07-25-2005, 10:49 AM   #9 (permalink)
Senior Member
 
nomis135's Avatar
Join Date: Mar 2005
Location: Quebec, Canada
Posts: 2,023
nomis135 is a name known to allnomis135 is a name known to allnomis135 is a name known to allnomis135 is a name known to allnomis135 is a name known to allnomis135 is a name known to allnomis135 is a name known to allnomis135 is a name known to all
 



you should make a site with these tutorials as lots of people don't know how to use shell.
There aren't tons of tutorials for that either.

If you know of any place with all the basic commands shown that would be cool as i don't know much of them. Only a few.
nomis135 is offline  
Old 07-25-2005, 11:14 AM THREAD STARTER               #10 (permalink)
Account Closed
 
abdulmueid's Avatar
Join Date: Jun 2005
Location: Mozambique
Posts: 607
abdulmueid has a spectacular aura aboutabdulmueid has a spectacular aura about
 



i guess i'll make a list and post soon
abdulmueid is offline  
Old 07-26-2005, 05:18 PM   #11 (permalink)
Account Suspended
Join Date: Jul 2005
Location: Pakistan
Posts: 194
Pakinium is an unknown quantity at this point
 



Great Tutorial ,

Repo Added !
Pakinium is offline  
Old 07-27-2005, 02:04 AM   #12 (permalink)
NamePros Regular
Join Date: Jul 2005
Posts: 247
coolpix is an unknown quantity at this point
 



Nice tutorial and thanks for sharing!
__________________
AIMForum.com - Ready, AIM, Chat!

Forum Elves - Quality Forum Posting At Affordable Prices! - Order A Package
coolpix is offline  
Old 07-28-2005, 12:27 AM   #13 (permalink)
NamePros Regular
Join Date: Jul 2005
Posts: 851
domainprince is on a distinguished road
 



Great, thanks for sharing!

Originally Posted by nomis135
you should make a site with these tutorials as lots of people don't know how to use shell.
????: NamePros.com http://www.namepros.com/showthread.php?t=109303
There aren't tons of tutorials for that either.
I second that.
domainprince is offline  
Old 07-29-2005, 01:08 PM THREAD STARTER               #14 (permalink)
Account Closed
 
abdulmueid's Avatar
Join Date: Jun 2005
Location: Mozambique
Posts: 607
abdulmueid has a spectacular aura aboutabdulmueid has a spectacular aura about
 



I have created a section dedicated to shells on my website at www.crazylittleworld.com

Click here to access the archive for shell.
abdulmueid is offline  
Old 08-12-2005, 11:21 AM   #15 (permalink)
Account Closed
 
thestudent's Avatar
Join Date: Aug 2005
Location: Canada
Posts: 491
thestudent is just really nicethestudent is just really nicethestudent is just really nicethestudent is just really nice
 



Nice Tutorail Abdul.Mueid
thestudent is offline  
Old 08-24-2005, 08:18 AM   #16 (permalink)
NamePros Member
Join Date: Aug 2005
Posts: 198
Red Eyes Arena is an unknown quantity at this point
 



that's cool never knew i can use shell with mysql ^^
Red Eyes Arena is offline  
Old 08-27-2005, 09:17 AM   #17 (permalink)
Senior Member
 
bbalegere's Avatar
Join Date: Jul 2005
Location: Bangalore
Posts: 1,271
bbalegere is just really nicebbalegere is just really nicebbalegere is just really nicebbalegere is just really nicebbalegere is just really nice
 



Amazing tutorial.
bbalegere is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
HOWTO: Install the Apache Web Server, Perl, PHP, and MySQL on Windows deadserious Webmaster Tutorials 96 05-27-2007 02:24 PM
Tutorial: How to Install Apache2 MySQL and PHP on Windows deadserious Webmaster Tutorials 35 09-21-2005 10:46 PM
database transfer domainabilities Programming 2 02-15-2005 09:00 PM
Tutorial: Getting Started With MySQL (The Basics) deadserious Webmaster Tutorials 3 04-18-2004 02:17 PM

Liquid Web Smart Servers  
All times are GMT -7. The time now is 02:04 PM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger