Skip to main content

MySQL School

Basic Setup of MySQL Server (windows only)

- shutting down MySQL server
mysqladmin -u root -p shutdown

- removing service
mysqld --remove

- installing service
mysqld-max --install

- starting up for first time
mysqld-max --standalone


Basic Setup of MySQL Server (all systems)

- first login

mysql -u root

- startup
mysqld --standalone

- setting up root password
set password for root@localhost=password('newpassord');
type your password instead of newpassword

- login as root
mysql -u root -p

- deleting anonymous accounts
use mysql;
delete from user where User='';
delete from db where User='';
flush privileges;

- create new user
grant create, create temporary tables, delete, execute, index, insert, lock tables, select, show databases, update on *.* to username identified by 'password';
type your username instead of username and password instead of password


Basic Commands

- showing databases
show databases;

- using database
use dbname;
type db name instead of dbname

- show tables in database
show tables;

- show table structure
describe tablename;
type your table name instead of tablename

- import commands from file
source filename
type the wanted file name instead filename with extension (full name)

- import commands from file (external)
mysql -u username -p < filename
type username instead of username and file name instead of filename with extension (full name)

- exit mysql
/q or quit

- help in mysql
/h


Data Bases and Tables Manipulation

- create database
create database dbname;
type data base name instead of dbname

- delete database
drop database dbname;
type data base name instead of dbname


to be continued...

Comments