LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-23-2003, 10:21 AM   #1
BaerRS
Member
 
Registered: Oct 2001
Location: Columbus, Ohio
Distribution: all.. but mainly SuSe--- looks like it changing to Red Hat
Posts: 119

Rep: Reputation: 15
MySql & phpMyAdmin & mysqldump


OK... I think I've found my problem.. I just don't know how to fix it...

I am trying to automate the back up of my mysql database... and then I would like to beable to restore the db vi phpmyadmin.. if needed....

here's a condensed version of the script I use to do the back up....
Code:
# This location is where the backups are saved to disk
LOCATION="/home/someplace/backup"

# This is where your exec file for mysqldump is located.
MYSQLDUMP="/usr/bin/mysqldump"

# This file has all the mysql database names in it.
# Ex. mysql_backup file
#
# 
# database_name
# 
# 
#
MYSQLDBNAME="/home/someplace/mysql_backup"

# Your Mysql user and passwd.
# Rember this account needs access to all databases.
SQLUSER="someuser"
SQLPASS="mypassword"

DATABASES=`cat $MYSQLDBNAME`
for dbname in $DATABASES
do
$MYSQLDUMP -u$SQLUSER -p$SQLPASS ${dbname} > $LOCATION/${dbname}.mysqlbackup
chmod 440 $LOCATION/${dbname}.mysqlbackup
#chown $STAMP $LOCATION/${dbname}.mysqlbackup
done


The first 28 lines are below:
Code:
-- MySQL dump 8.22
--
-- Host: localhost    Database: database-name
---------------------------------------------------------
-- Server version	3.23.54

--
-- Table structure for table 'adminblock'
--

CREATE TABLE adminblock (
  title varchar(60) default NULL,
  content text
) TYPE=MyISAM;

--
-- Dumping data for table 'adminblock'
--


INSERT INTO adminblock VALUES ('Administration Menu','Admin tools for the Web Technology Group\r\n<br /><span class=\"onebiggerred\">></span>\r\n<a href=\"admin.php\">Administration</a>\r\n<br /><span class=\"onebiggerred\">></span>\r\n<a href=\"admin.php?op=logout\">Logout</a>\r\n');
INSERT INTO adminblock VALUES ('Administration Menu','Admin tools for the Web Technology Group\r\n<br /><span class=\"onebiggerred\">></span>\r\n<a href=\"admin.php\">Administration</a>\r\n<br /><span class=\"onebiggerred\">></span>\r\n<a href=\"admin.php?op=logout\">Logout</a>\r\n');

--
-- Table structure for table 'authors'
--

CREATE TABLE authors (.....bla bla bla..........
if I do a back up via phpMyadmin with structure and data... the out put is below...:

Code:
# phpMyAdmin MySQL-Dump
# version 2.2.4
# http://phpwizard.net/phpMyAdmin/
# http://phpmyadmin.sourceforge.net/ (download page)
#
# Host: localhost
# Generation Time: Jan 23, 2003 at 09:55 AM
# Server version: 3.23.54
# PHP Version: 4.2.3
# Database : `database-name`
# --------------------------------------------------------

#
# Table structure for table `adminblock`
#

CREATE TABLE adminblock (
  title varchar(60) default NULL,
  content text
) TYPE=MyISAM;

#
# Dumping data for table `adminblock`
#

INSERT INTO adminblock VALUES ('Administration Menu', 'Admin tools for the Web Technology Group\r\n<br /><span class="onebiggerred">></span>\r\n<a href="admin.php">Administration</a>\r\n<br /><span class="onebiggerred">></span>\r\n<a href="admin.php?op=logout">Logout</a>\r\n');
INSERT INTO adminblock VALUES ('Administration Menu', 'Admin tools for the Web Technology Group\r\n<br /><span class="onebiggerred">></span>\r\n<a href="admin.php">Administration</a>\r\n<br /><span class="onebiggerred">></span>\r\n<a href="admin.php?op=logout">Logout</a>\r\n');
# --------------------------------------------------------

#
# Table structure for table `authors`
#

CREATE TABLE authors (.....again...bla...bla...bla...
the difference is.. myssqldump is giving me "--".. where phpmyadmin is giving me "##" for comments...

could someone tell me how to get mysqldump to output so phpmyadmin can restore the database....

phpmyAdmin Ver ?? I have ask for the vers.. not sure yet
mysql client Ver 3.23.39
php Ver 4.2.3-1

Sorry this is so long.. but I wanted to try to give you all the info that someone might need....

Scott

Last edited by BaerRS; 01-23-2003 at 10:31 AM.
 
Old 01-23-2003, 11:01 PM   #2
wdingus
Member
 
Registered: Aug 2001
Location: Kingsport, TN
Distribution: RHEL & FC
Posts: 267

Rep: Reputation: 30
You've already tried and phpMyAdmin won't import these dump files because of differences in the # and - characters?

Maybe not the answer you want but importing command-line is very easy.

# mysql -uroot -pyourpassword database_name <dumpfile.sql

I usually include an --opt as a command-line mysqldump option. It will re-import much faster and includes "drop if exists" on a per-table basis. So If you're importing over top of existing data it won't bomb out.

Hope that helps.
 
Old 01-24-2003, 10:05 AM   #3
BaerRS
Member
 
Registered: Oct 2001
Location: Columbus, Ohio
Distribution: all.. but mainly SuSe--- looks like it changing to Red Hat
Posts: 119

Original Poster
Rep: Reputation: 15
Thanks wdingu...

Well I ended up restoring vi a command line.. I'll check out the --opt option.. When I made the backup vi.. phpMyAdmin.. it worked fine on a smaller database.. when restored vi phpMyAdmin.. but on the lager databases.. this took forever.. and wasn't always successful.

So.. like most things I've come across.. the gui can make it easier for basic day to day operations.. but the power comes from the command line...

Don't know why I always fight with my self with this.. and keep looking for that perfect "gui" tool...

Scott
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Japanese canna won't work : Warning: &#12363;&#12394;&#28450;&#23383;&#22793;&am OrganicOrange84 Debian 3 06-30-2005 03:28 PM
Ph&#7909;c h&#7891;i d&#7919; li&#7879;u b&#7883; m&#7845;t???, c&#7913; pollsite General 1 06-27-2005 01:39 PM
mysql / phpmyadmin & fedora fuelinjection Linux - General 2 06-20-2005 11:28 PM
From RedHat9 to FreeBSD (Apache 2 & Mysql & PHP 4) guardian653 *BSD 5 12-11-2003 06:31 PM
phpMyAdmin & MySQL Staz Linux - Software 0 09-26-2002 08:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration