1、创建一个数据库:
create database db_test;
2、创建一个表:
MySQL [mysql]> use db_test;
Database changed
MySQL [db_test]> create table tb_test ( id int(11) primary key, name varchar(25), salary float );
Query OK, 0 rows affected (0.37 sec)
3、查看表结构:
MySQL [db_test]> desc tb_test;
+--------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| id | int(11) | NO | PRI | NULL | |
| name | varchar(25) | YES | | NULL | |
| salary | float | YES | | NULL | |
+--------+-------------+------+-----+---------+-------+
4、向表内插入数据和查看数据:
MySQL [db_test]> insert into tb_test (id,name,salary) VALUES(1,'斯**',*000),(2,'刘**',*000);
Query OK, 2 rows affected (0.07 sec)
Records: 2 Duplicates: 0 Warnings: 0 MySQL [db_test]> select * from db_test.tb_test;
+----+-----------+--------+
| id | name | salary |
+----+-----------+--------+
| 1 | 斯** | *000 |
| 2 | 刘** | *000 |
+----+-----------+--------+
2 rows in set (0.03 sec)
※ 为MySQL的root用户设置密码(在第一次安装完后):
mysqladmin -u root password 'newpassword'
※
※
※
※
※