You are on page 1of 3

MySql Installation on Windows

Download MySql from

https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.25-winx64.zip

extract mysql

Then create a folder where database data will be stored, such


as C:\mysqldata. Using a folder outside of C:\mysql is safer
and allows you to upgrade application files.

Now create a my.ini file in C:\mysql which specifies the


application and data folders.
[mysqld]
# installation path
basedir=C:/mysql
# data directory
datadir=E:/mysqldata

Initialize server user


C:\mysql\bin\mysqld.exe --initialize-insecure

Start Server
C:\mysql\bin\mysqld.exe --console

Use the MySQL client by entering C:\mysql\bin\mysql.exe -u


root in another console. You can now issue SQL commands such
as show databases; and quit by typing exit.
Server shutdown
C:\mysql\bin\mysqladmin.exe -u root shutdown

CREATE USER

CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';

PERMISSION

GRANT type_of_permission ON database_name.table_name TO 'username'@'localhost';

REVOKE type_of_permission ON database_name.table_name FROM 'username'@'localhost';

SHOW GRANTS FOR 'username'@'localhost';


DROP USER 'username'@'localhost';

Quit

mysql -u [username] -p

CREATE DATABASE new_database;

CREATE DATABASE IF NOT EXISTS new_database;

SHOW DATABASES;

SELECT database();

USE new_database;
SELECT database();

DROP DATABASE new_database;


DROP DATABASE IF EXISTS new_database;

CREATE TABLE IF NOT EXISTS equipment (


equip_id int(5) NOT NULL AUTO_INCREMENT,
type varchar(50) DEFAULT NULL,
install_date DATE DEFAULT NULL,
color varchar(20) DEFAULT NULL,
working bool DEFAULT NULL,
location varchar(250) DEFAULT NULL,
PRIMARY KEY(equip_id)
);

show columns in equipment;

INSERT INTO equipment (type, install_date, color, working, location)


VALUES
("Slide", Now(), "blue", 1, "Southwest Corner");

SELECT * FROM equipment;


INSERT INTO equipment (type, install_date, color, working, location)
VALUES
("Swing", Now(), "green", 1, "Northwest Corner");

DROP TABLE table_name;

SHOW tables;

DROP TABLE equipment;

SHOW tables;

You might also like