Mysql Tutorial

MySQL is a relational database management system that runs as a server providing multi-user access to a number of databases. MySQL works on many different system platforms. In this guide we will test mysql on two machines, Windows and Linux.

MySQL  shell client command

How to run MySQL commands on Windows?

Go to the "Start > MySQL > MySQL Server 5.1 > MySQL Command Line Client" or open your DOS Windows. Type "mysql -u root -p" and enter your MYSQL password.

How to run MySQL commands on Linux ?

 Open a terminal and type "mysql -u root -p".

  • How to check MySQL version?
    mysql> select version();
    +------------------+
    | version()        |
    +------------------+
    | 5.1.58-community |
    +------------------+
    1 row in set (0.00 sec)
  • List all databases on the sql server 
    mysql> show databases;
  • Switch to a database
    mysql> use [db name]; 
  • To see all the tables in the db 
    mysql> show tables;
  • To see database's field formats
    mysql> describe [table name];
  • To delete a database
    mysql> drop database [database name];
  • To delete a table
    mysql> drop table [table name];
  • Show all data in a table
    mysql> SELECT * FROM [table name];
  • Delete a row(s) from a table
    mysql> DELETE from [table name] where [field name] = 'whatever';
  • Show the columns and column information of the table
    mysql> show columns from [table name];
  • Recover a MySQL root password
    mysql> use mysql;
    mysql> update user set password=PASSWORD("new password") where User='root';
    mysql> flush privileges;
    mysql> quit

How to convert a SQLITE table to a MYSQL table?

First, go to  firefox  site and install this browser to your computer. Install firefox "SQLite Manager" tool to manage any SQLite database on your computer. Refresh (reload) your firefox browser. Go to the firefox "Tools" button and click on to  select "SQLite Manager".

Connect Database > Database > Table > Export > SQL > filename.sql
  • select your sqlite database from the "SQLite Manager" window
  • select the table to be converted to SQL table
  • select Export button
  • select SQL button and save the file as SQL file

Links

  1. Mysql.com
  2. SQLITE Manager - add ons for Firefox