鏈接mysqlphp
mysql -hlocalhost -uroot -p
查看當前數據庫mysql
SHOW DATABASES;
建立數據庫shopsql
CREATE DATABASE shop
刪除數據庫shop數據庫
DROP DATABASE shop
選擇(打開)數據庫shopide
USE shop
查看當前操做數據庫裏面的全部表it
SHOW TABLES
查看某一張表的結構(例:user表)class
DESC user;
建立一張user表im
CREATE TABLE user( id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, username CHAR(20) NOT NULL, password CHAR(32) NOT NULL, UNIQUE KEY username(username) )ENGINE = INNODB DEFAULT CHARSET =UTF8;
刪除一張表數據
DROP TABLE user;
向表裏面插入一條數據查詢
INSERT INTO user(id,username,password) values(null,'wangzherongyao',20);
更新一條數據
UPDATE user set password = 'mima123456' where username='wangzherongyao';
刪除一條數據
DELETE FROM user where id=1;
查詢語句
SELECT * FROM user where id=1;