How to create a MySQL database

.. this is quick & dirty. See the MySQL Memo (french) for details.

Mysql Administrators

mysqladmin --password=yyyy create dbnamezzzz
mysql mysql -u xxxx --password=yyyy < ~xxx/mysql/mysql.dump
mysqladmin -u xxxx --password=yyyy reload


  1. Ask P.J. or D.S. to give you a database. You will get:
    A database name: e.g. juliette
    A database priviledged user name: e.g. juliette or julie
    A password for this user, e.g. ax45x
  2. Your db might NOT have the right permission, e.g. by default we only give read access to "nobody", enquire with P.J. or D.S. !!
  3. Create tables:
    It is best to define your tables in some file, e.g. 'mysql.defs'. Then log onto and pipe the file into mysql.
    mysql juliette --user=julie --password=ax45x < ~julie/mysql.defs


A Mysql table definition for the db juliette:
# mysql Dump

# Host: localhost    Database: juliette

# Table structure for table 'test'
# DROP TABLE test;
  id int(10) DEFAULT '0' NOT NULL auto_increment,
  field1 char(10) NOT NULL,
  field2 char(30),
  KEY field1 (field1)

A few PHP commands (see the php/mysql demo for more details):

<? $link = mysql_connect( "localhost", "nobody", ""); ?>
Will connect you to the mysql server with id = nobody. In web
pages this is what you'd usually use (for consulations at least).

<? $link = mysql_connect( "localhost", "julie", "xyz"); ?>
This will connect you as "julie"

<? mysql_select_db("juliette", $link);?>
This will select a db for you.

$result  =  mysql_query( "select  *  from  test  limit  100"); 
Will select the first 100 rows from table "test".

while  ($row  =  mysql_fetch_row($result))  { 
    for  ($i=0;  $i

Back to the MySql page