看一下mysql的版本信息:
? ~ brew info mysql
mysql: stable 5.7.16 (bottled)
打開mysql服務:
mysql.server start
好了,進入mysql看下:
? ~ mysql -u root -p
mysql查看表結構命令,如下:
desc 表名;
show columns from 表名;
describe 表名;
show create table 表名;
use information_schema
select * from columns where table_name='表名';
查看數(shù)據(jù)庫:
show databases;
// 使用數(shù)據(jù)庫
use 數(shù)據(jù)庫名;
show tables;
創(chuàng)建數(shù)據(jù)庫,創(chuàng)建表。
mysql> create database ssh2;
mysql> use ssh2;
mysql> create table user(
-> id integer primary key,
-> firstname varchar(200) not null,
-> lastname varchar(200) not null,
-> age integer
-> );
給主鍵增加一個自增的功能:
mysql> alter table user modify id integer auto_increment;
這樣,上面的user表里面的主鍵,id可以自增了。
鏈接:
http://stevenjohn.iteye.com/blog/976397
增刪改查:http://blog.chinaunix.net/uid-20672803-id-3049747.html
php操縱數(shù)據(jù)庫:http://www.runoob.com/php/php-mysql-select.html