Project

General

Profile

Actions

PostgreSQLInstallDebianEtch » History » Revision 2

« Previous | Revision 2/10 (diff) | Next »
Lutz Suhrbier, 11/02/2007 03:05 PM


MySQL Installation on Debian Etch

Installing PostgreSQL

Currently, PostgreSQL versions 7.5.22 and 8.1.9 are included within the stable release of Debian Etch.

This installs PostgreSQL 7.5.22

# apt-get install postgresql

This installs PostgreSQL 8.1.9

# apt-get install postgresql-8.1

Installing the Python Interface to PostgreSQL

In order to use PostgreSQL within Python-scripts, the package python-psycopg2 should be installed.

# apt-get install python-psycopg2

Installing the PHP Interface to MySQL

In order to use MySQL within PHP-scripts, the package php5-pgsql must be installed.

# apt-get install php5-pgsql

Configuring PostgreSQL

Create Administration Account

In order to get working with PostgreSQL, at least on user (e.g. "root") acting as database administrator must be created in MySQL.

# mysqladmin -u root password 'secret'

Create Database

Usually, applications require an empty database for setup. An empty database (e.g. "emptyDB") can be created with the following command.

# mysqladmin -u root -p create emptyDB

Using the --password option, you will not be prompted for a password (replace secret with your password).

# mysqladmin -u root --password='secret' create emptyDB

Granting Access Rights to a Database

If you want to assign all access rights on a database (e.g. emptyDB) to the user root, enter the one of the following commands(the password option is also available for the mysql command):

# mysql -u root -p

or without password prompting

# mysql -u root --password='secret'

Then, a MySQL console opens where you should enter the following command.

GRANT ALL PRIVILEGES ON drupal.* TO root;

The answer should be

'Query OK, 0 rows affected'.

Now, activate the database and leave the MySQL console

flush privileges;
exit;

If you like to introduce an specific database administrator, you may add another user to MySQL and granting privileges to him, e.g.

# mysql -u root --password='secret'
GRANT ALL PRIVILEGES ON emptyDB.* TO emptyDB@localhost IDENTIFIED by 'secret';
'Query OK, 0 rows affected'.
flush privileges;
exit;

Backup Databases

In order to backup databases or tables, use one of the following_mysqldump_ command lines.

# mysqldump [options] db_name [tables]
# mysqldump [options] --databases db_name1 [db_name2 db_name3...]
# mysqldump [options] --all-databases

For instance, if you want to backup the database exampleDB completely, the following command line stores the database exampleDB into the SQL-script file named exampleDB.sql

# mysqldump -u root --password='secret' exampleDB > exampleDB.sql

Import Databases

Databases can be imported into MySQL by executing SQL-script files, formerly generated by a database backup or manually.

The following commands imports the database from the file exampleDB.sql into the exampleDB database.

# mysql -u root --password='secret' exampleDB < /root/bdtracker/exampleDB.sql;

Delete Databases

To delete databases from MySQL, use the DROP DATABASE within the MySQL console.

# mysql -u root --password='secret'
DROP DATABASE exampleDB;
'Query OK, 0 rows affected'.
exit;

Updated by Lutz Suhrbier over 16 years ago · 2 revisions