MySQL basics
A brief tutorial on using MYSQL
So, you have an Apache, PHP, and MySQL setup on Windows. This is what you need to do next.

(1) MySQL Root Password

Make sure you know the root password of MySQL. If not, then you can use several techniques from the manuals at MySQL.com to reset the password. Briefly one method is

i. Stop the mysql service

ii. Create a text file called c:\resetpass.txt and place the following command within it on a single line:

SET PASSWORD FOR ‘root’@'localhost’ = PASSWORD(‘MyNewPassword’);

iii. At the DOS command prompt, (assuming that mysql is under c:\) execute this command:

C:\> C:\mysql\bin\mysqld –init-file=C:\\resetpass.txt

The contents of the file named by the –init-file option are executed at server startup, changing the root password. Note that there should be two backslashes after C: above.

(2) New User

Create a user for your web service/application

Start the mysql interpreter by typing

C:\mysql\bin\mysql -h localhost -u root -p

Now you can type SQL commands into the interpreter. The one for creating a user called mydb_admin is (note that in the mysql interpreter you must put a semicolon at the end of a command)

CREATE USER 'mydb_admin'@'localhost' IDENTIFIED BY 'mypassword';

(3) Create a Database

This command creates a database called mydb.

CREATE DATABASE mydb;

(3.1) Show a List of the Databases

This command displays all of the databases on the server.

SHOW DATABASES;

(3.2) Select a Database

This command selects the databases named mydb. Operations will then occur by default onto mydb until another database is selected.

USE mydb;

(3.3) Delete a Database

This command deletes a database named mydb.

DROP DATABASE mydb;

(4) Privileges

Grant the user mydb_admin privileges to manipulate the database

GRANT ALL ON mydb.* TO 'mydb_admin'@'localhost';

Useful Commands

To see all of the users on your mysql server

SELECT USER FROM mysql.user;

To see all of the tables in a database

SHOW TABLES FROM mydb;

To see the columns from a table called teams

SHOW COLUMNS FROM mydb.teams;

To delete (drop) a table

DROP TABLE mydb.teams;

To delete a row from a table

DELETE FROM mydb.teams WHERE name='yankees';

Now in principle, you have a new database within which you can add tables, and a user who can manipulate the database.

Media Lab Overview
LIACS Homepage
MM Conf
ACM Multimedia
ACM ICMR
IAPR ICPR
Science Direct
IEEE Library
LIACS Publications
ACM Digital Library