mysql

using mysql

allow remote access on the mysql server if you want to connect from a remote client:
edit /etc/my.cnf
change bind-address = 192.158.5.1 to bind-address =
comment out: skip-networking (didnt need doing on my system)

login:
mysql -u root -p
mysql -u -h -p

list databases:
show databases;

new database:
create database contacts;

give access to database (I need to understand more on this):
GRANT ALL ON employees.* TO david@localhost IDENTIFIED BY "mypass";

use a database:
use contacts;

list the tables in the db:
show tables;

show table details:
describe name;

make a table:
CREATE TABLE name(
fieldID int not null auto_increment primary key,
field1 VARCHAR(20),
field2 TEXT,
field3 TINYTEXT,
field4 INT UNSIGNED);

remove a table:
drop table name;

adding data:
insert into contacts (field list) values (value list);
if the value list contains all the fields you can skip the fields list.

showing data:
select fields from contacts;
select fields from contacts where cFirstName="david";
select fields from contacts order by cFirstName;
select fields from contacts limit 4;
select distinct cLastName from contacts;
select min(salary) from packages;
select count(*) from contacts;
select concat(cFirstName, " ", cLastName) from contacts;

changing data:
update contacts set cFirstName="cass" where cFirstName="cassandra";
delete from contacts where cFirstName = "cass";
alter table contacts add birthdate date;
update contacts set cBirthdate="2000-10-20" where cFirstName="david";

first table join:
select * from contacts join cemail on contacts.contactID = cemail.contactID;