MySQL创建用户并添加权限的方式:
1.进入mysql数据库
mysql -u root mysql
2.在mysql界面添加用户及权限
create user 'pyjsh'@'localhost' identified by 'pyjsh';
grant all on *.* to pyjsh@'%' identified by 'pyjsh';
grant all on *.* to pyjsh@'localhost' identified by 'pyjsh';
flush privileges;
查询数据库
show databases;
创建数据库
create database dbname;
删除数据库
drop database dbname;
创建数据库表并设置自增长主键
MariaDB [dyf_da]> create table test_tb
-> (
-> id int(11) not null AUTO_INCREMENT primary key,
-> total int(11),
-> name varchar(256));
Query OK, 0 rows affected (0.021 sec)
查看数据表结构
desc test_tb;
show columns from test_tb; 和上条命令查询结果一致
向数据表中插入列
alter table test_tb add column age varchar(256);