How to create MySQL database using command prompt?
1. First thing you need to do, download XAMPP or WAMP servers.
2. After downloading it, obviously you need to install it.
3. Open XAMPP or WAMP (Any servers will do, they have the same GUI)
2. After downloading it, obviously you need to install it.
3. Open XAMPP or WAMP (Any servers will do, they have the same GUI)
4. Run MySQL by clicking the START button (based on the image above). Apache is for web servers. You only need Apache when running web services.
5. Open Command Prompt and type the following:
cd. . (to change directories, will direct you to the location of the server either you installed it in C: or D:)
cd xampp/mysql/bin (direct you inside the bin folder)
mysql -u root -p (logging in to MySQL, defaults: localhost, username is "root", password is "")
5. Open Command Prompt and type the following:
cd. . (to change directories, will direct you to the location of the server either you installed it in C: or D:)
cd xampp/mysql/bin (direct you inside the bin folder)
mysql -u root -p (logging in to MySQL, defaults: localhost, username is "root", password is "")
6. You are now inside MySQL. You can create the database and the tables here.
Syntax:
CREATE DATABASE sample_db (creates the database)
USE sample_db (use database on the next transactions)
CREATE TABLE tb_name (id int not null primary key auto_increment,name varchar(30) not null); NOTE: This are just basics, you can set the primary key whether to make it auto increment or to make it unique.
Syntax:
CREATE DATABASE sample_db (creates the database)
USE sample_db (use database on the next transactions)
CREATE TABLE tb_name (id int not null primary key auto_increment,name varchar(30) not null); NOTE: This are just basics, you can set the primary key whether to make it auto increment or to make it unique.
7. You can now view the tables you created by typing "desc (table name);" without quotes. Example: desc tb_name;