初始化mysql
mysql_secure_installation
登录mysql
mysql -uroot -p
• 显示数据库 • mysql> show databases;
• 显示数据库中的表
use 库名 • mysql> show tables;
显示数据表的结构
mysql> describe 表名 ;
• 显示表中的记录 select * from 表名 ;
• 建库
create database 库名 ;
• 建表
use 库名; create table 表名 ( 字段设定列表 ) ;
• 增加记录
mysql> insert into name values( 数据 );
• 修改纪录
mysql> update 表名 set .... where ....;
• 删除纪录
mysql> delete from 表名 where ....;
• 删库和删表
drop database 库名 ;
drop table 表名;
• 增加 MySQL 用户
mysql> grant select,insert,update,delete on *.* to
user_1@"%" identified by "123";
mysql>grant select,insert,update,delete on aaa.* to
user_2@localhost identified by "123";
• 重载 Mysql 的授权表
Mysql>flush privileges;