Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
| Search | Today's Posts | Mark Forums Read
MySQL General discussion about the MySQL database.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the MySQL section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old September 6th, 2007, 10:44 AM
Registered User
 
Join Date: Sep 2007
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Aprile
Default separate file location for different databases

Hi, everyone. I'd really appreciate it if someone could help me with this.

We're running MySQL 5.0.22 on a CentOS 5 virtual machine. We need to add another database to our MySQL system, because the volume that stores databases is filling up quickly. We've created another volume, and now we need to be able to create the new database in the new volume without moving the old one. Any help would be great.

Thanks in advance.



Aprile
www.accessdatabaserepair.com - Access Repair Tool
  #2 (permalink)  
Old September 6th, 2007, 04:34 PM
Friend of Wrox
 
Join Date: Jul 2003
Location: South San Francisco, CA, USA.
Posts: 128
Thanks: 0
Thanked 1 Time in 1 Post
Default

Aprile,
You need first to backup your current database.
Then create a new database.

The syntax in creating a new database is:

CREATE DATABASE [IF NOT EXISTS] db_name;

Then COPY the syntax of the tables you on your existing database.
The syntax to know how your existing tables were created is:
DESCRIBE city;
+------------+----------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+----------+------+-----+---------+----------------+
| Id | int(11) | | PRI | NULL | auto_increment |
| Name | char(35) | | | | |
| Country | char(3) | | UNI | | |
| District | char(20) | YES | MUL | | |
| Population | int(11) | | | 0 | |
+------------+----------+------+-----+---------+----------------+

then with the above syntax create a table.
Example:
CREATE TABLE IF NOT EXISTS city(
  Id int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  Name char(35),
  Country char(3) NOT NULL UNIQUE,
  District char(20),
  Population int(11) default '0',
  PRIMARY KEY (Id),
  INDEX (country),
  INDEX (district)
) ENGINE=InnoDB;


i hope this helps.
Good luck!
John






Similar Threads
Thread Thread Starter Forum Replies Last Post
File Location AlexSepahpour ASP.NET 2.0 Basics 0 March 11th, 2007 12:58 AM
Configuration file name and location TomH VB Databases Basics 2 September 29th, 2006 06:59 PM
file upload processed on separate page vauneen ASP.NET 2.0 Professional 0 August 8th, 2006 03:03 AM
Access report print each page to separate PDF file conh2so4aq Access VBA 5 July 3rd, 2006 08:00 PM
problem for creating the separate log file for con goel_man Apache Tomcat 0 December 19th, 2004 11:48 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.