mysql 命令集锦



mysql -h host -u user -p

select version(),current_date;

select user();

select sin(pi()/4),4-2*4;

select now();

show databases;

use test

grant all privileges on *.* to 'andy'@localhost' identified by 'password' with grant option;

grant all privileges on *.* to 'andy'@'%' identified by 'password' with grant option;

alter table andy add weight varchar(3) after sex;

alter table andy rename andy01;

alter table andy drop weight;

alter table andy modify name vharchar(20);


mysql> create table data (
    -> id char(2) primary key,
    -> name varchar(8),
    -> sex varchar(2),
    -> birthday date,
    -> blood varchar(2),
    -> cellphone char(8),
    -> privatephone char(8)
    -> );


mysql> create table partandy (
    -> id char(2) primary key )
    -> select id,name,sex from data;


mysql> use mysql
mysql> select host,user,password from user;    //查看mysql用户


load data local '/path/name.txt' into table name lines terminated 'r\n';

insert into name values ('','','',null);



create table MyTable
(user_id smallint,
username char(22),
password char(22),
email char(30));

alter table MyTable add tel_no char(22);

drop talbe MyTablel;



你可能感兴趣的:(mysql,数据库,命令,职场,休闲)