mysql command to create database and table

  1. command to Connect to mysql database
mysql>mysql -u root -h 192.168.15.204 -P 3306 -p password
2. Command to check existing databases list
mysql>show databases;
+——————–+
| Database |
+——————–+
| information_schema |
| chk |
| mysql |
| test |
| worldpress1 |
+——————–+
5 rows in set (0.03 sec)
3. Command to create new database
mysql>create database regi;
to use new created database
mysql>use regi;
4. Command to create tables in my sql database 

mysql> CREATE TABLE users ( id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, username VARCHAR (20), email VARCHAR (20), password VARCHAR (20));
5. command to check detailed description of table structure :-
mysql> desc users;mysql> desc users;
+———-+————-+——+—–+———+—————-+
| Field | Type | Null | Key | Default | Extra |
+———-+————-+——+—–+———+—————-+
| id | int(11) | NO | PRI | NULL | auto_increment |
| username | varchar(20) | YES | | NULL | |
| email | varchar(20) | YES | | NULL | |
| password | varchar(20) | YES | | NULL | |
+———-+————-+——+—–+———+—————-+
4 rows in set (0.00 sec)

6. command to insert data into mysql database command line..


mysql>insert into stu (stuname,email,city,contact) values 
                         
         ('rajesh','rajesh@gmail.com','delhi','011-32524456');




Previous Post
Next Post
Related Posts

0 Comments: