mysql> create table students(
-> student_id INT UNSIGNED,
-> name VARCHAR(30),
-> sex CHAR(1),
-> birth DATE,
-> PRIMARY KEY (student_id)
-> );
Query OK, 0 rows affected (0.01 sec)
mysql> desc students
-> ;
+------------+------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+------------------+------+-----+---------+-------+
| student_id | int(10) unsigned | NO | PRI | 0 | |
| name | varchar(30) | YES | | NULL | |
| sex | char(1) | YES | | NULL | |
| birth | date | YES | | NULL | |
+------------+------------------+------+-----+---------+-------+
4 rows in set (0.01 sec)
mysql> insert into students(student_id,name,sex,birth) values(41048101,'Lucy Green','1','1990-02-14');
Query OK, 1 row affected (0.01 sec)
mysql> select * from students;
+------------+------------+------+------------+
| student_id | name | sex | birth |
+------------+------------+------+------------+
| 41048101 | Lucy Green | 1 | 1990-02-14 |
+------------+------------+------+------------+
1 row in set (0.00 sec)
mysql> commit;
Query OK, 0 rows affected (0.00 sec)
mysql> select name from students where student_id = 41048101;
+------------+
| name |
+------------+
| Lucy Green |
+------------+
1 row in set (0.01 sec)
JDBC
Java Data Base Connectivity (java 数据库连接) 用于Java应用程序连接数据库的标准方法,是一种用于执行SQL语句的Java API,
可以为多种关系数据库提供统一访问,它由一组用Java语言编写的类和接口组成。
Mysql 版本:
-bash-4.1$ mysql -V
mysql Ver 14.14 Distrib 5.6.16, for Linux (x86_64) using EditLine wrapper
mysql> select version();
+-----------+
| version() |
+-----------+
| 5.6.16 |
+-----------+
1 row in set (0.00 sec)
1.4 Mysql 工具:
-bash-4.1$ ps -ef | grep mysql | grep -v grep | grep -v ps | grep -v bash
root 557 48793 0 Mar05 pts/9 00:00:00 su - mysql
root 48888 1 0 Mar05 pts/9 00:00:00 /bin/sh /usr/local/mysql5.6/bin/mysqld_safe --datadir=/usr/local/mysql5.6/data --pid-file=/usr/local/mysql5.6/data/dwh1.pid
mysql 49005 48888 0 Mar05 pts/9 00:00:02 /usr/local/mysql5.6/bin/mysqld --basedir=/usr/local/mysql5.6 --datadir=/usr/local/mysql5.6/data --plugin-dir=/usr/local/mysql5.6/lib/plugin --user=mysql --log-error=/usr/local/mysql5.6/data/dwh1.err --pid-file=/usr/local/mysql5.6/data/dwh1.pid
1) mysqld: SQL后台程序(即Mysql 服务器进程)。该程序必须运行之后,客户端才能连接服务器来访问数据库。
2)mysqld_safe:服务器启动脚本,在Unix 和NetWare中推荐使用mysqld_safe来启动mysqld服务器。mysqld_safe增加了
一些安全特性,例如当出现错误时重启服务器并向错误日志写入运行时间信息。