Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving copy of database and importing back into phpMyAdmin

Status
Not open for further replies.

gwnh2

Programmer
Dec 31, 2008
9
AU
Hi everyone,

i've created a database with a number of tables using phpMyAdmin. I'd like to use this particular database as a basis for a new database, ie. deleting some tables and adding others. Since I want to keep the original database intact, I've exported the original as a .sql file but I now need to save this version as a new version under a new database name and import it back into phpMyAdmin where I can edit it further.

The following is what part of the code looks like in the .sql file (ie. after I converted it to a .txt file so I could view it):

Code:
-- phpMyAdmin SQL Dump
-- version 2.11.7.1
-- [URL unfurl="true"]http://www.phpmyadmin.net[/URL]
--
-- Host: localhost
-- Generation Time: Jan 06, 2009 at 05:54 PM
-- Server version: 5.0.41
-- PHP Version: 5.2.6

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Database: `first_country_oam`
--

-- --------------------------------------------------------

--
-- Table structure for table `accessLevels`
--

CREATE TABLE `accessLevels` (
  `AccessLevelID` int(11) NOT NULL auto_increment,
  `AccessLevelName` varchar(50) default NULL,
  PRIMARY KEY  (`AccessLevelID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

--
-- Dumping data for table `accessLevels`
--


-- --------------------------------------------------------

--
-- Table structure for table `branches`
--

CREATE TABLE `branches` (
  `BranchID` int(10) NOT NULL auto_increment,
  `ClientNameFK` varchar(50) default NULL,
  `BranchContactFirstname` varchar(50) default NULL,
  `BranchContactLastname` varchar(50) default NULL,
  `BranchAddress1` varchar(50) default NULL,
  `BranchAddress2` varchar(50) default NULL,
  `BranchSuburb` varchar(50) default NULL,
  `BranchStateFK` varchar(50) default NULL,
  `BranchPostcode` varchar(50) default NULL,
  `BranchTel` varchar(25) default NULL,
  `BranchFax` varchar(25) default NULL,
  `BranchEmail` varchar(25) default NULL,
  PRIMARY KEY  (`BranchID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

--
-- Dumping data for table `branches`
--


-- --------------------------------------------------------

--
-- Table structure for table `clients`
--

CREATE TABLE `clients` (
  `ClientID` int(10) NOT NULL auto_increment,
  `ClientName` varchar(50) default NULL,
  `ClientContactFirstname` varchar(50) default NULL,
  `ClientContactLastname` varchar(50) default NULL,
  `ClientAddress1` varchar(50) default NULL,
  `ClientAddress2` varchar(50) default NULL,
  `ClientSuburb` varchar(50) default NULL,
  `ClientStateID` varchar(50) default NULL,
  `ClientPostcode` varchar(50) default NULL,
  PRIMARY KEY  (`ClientID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

--
-- Dumping data for table `clients`
--

Can someone tell me how I can import the database back into phpMyAdmin under another name?

Appreciate any help.
 
Suggestion but do so at your own risk, or at least wait to see if anyone highlights potential risks.
Make several backups, for security then rename the existing database.
Import the original back in should give you 2.


Keith
 
Thanks for the suggestion. I tried to rename the database and reimport it but it's giving me the following error:

Code:
Error
SQL query:

--
-- Database: `online_store`
--
-- --------------------------------------------------------
--
-- Table structure for table `accessLevels`
--
CREATE TABLE  `accessLevels` (
 `AccessLevelID` INT( 11 ) NOT NULL AUTO_INCREMENT ,
 `AccessLevelName` VARCHAR( 50 ) DEFAULT NULL ,
PRIMARY KEY (  `AccessLevelID` )
) ENGINE = MYISAM DEFAULT CHARSET = latin1 AUTO_INCREMENT =1;


MySQL said: 

#1050 - Table 'accessLevels' already exists


Does anyone know why this is happening?
 
You need to import into phpmyadmin 0 don't understand this do you mean use.
I guess you want to export a database and then import it into another database ?
Can you show us the command lines you are using ?
 
Hi there,

In phpmyadmin...you can simply select the database in question, then Click on Opertions, Copy Database to, NewName.

Choose either structure only or structure and data...

You're done.

HTH,

Peter.

Remember- It's nice to be important,
but it's important to be nice :)
 
Thanks so much - that's exactly what I needed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top