连接到MySQL:
mysql -u username -p password
创建数据库:
CREATE DATABASE dbname;
选择数据库:
USE dbname;
创建数据表:
CREATE TABLE tablename ( column1 datatype, column2 datatype, column3 datatype, ..... );
插入数据:
INSERT INTO tablename (column1, column2, column3, ...) VALUES (value1, value2, value3, ...);
查询数据:
SELECT * FROM tablename; SELECT column1, column2 FROM tablename; SELECT * FROM tablename WHERE column1 = 'value';
更新数据:
UPDATE tablename SET column1 = 'newvalue' WHERE column2 = 'value';
删除数据:
DELETE FROM tablename WHERE column1 = 'value';
删除数据表:
DROP TABLE tablename;
删除数据库:
DROP DATABASE dbname;