--连接远程数据库
mysql -h110.110.110.110 -P3306 -uroot -pabcd123
(注:u与root可以不用加空格,其它也一样)
--重设置密码
set password for root@localhost = password('root');
show databases;
CREATE DATABASE `taijs` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
select * from user1;
--切换数据库
use taijs;
select * from user1;
insert into user1 values(1,'孙悟空','斗战胜佛','13786868888');
--查看i安所有数据哭
show databases;
--查看所有表格
show tables;
desc user1;
--读取当前时间
select now();
--格式化时间
select DATE_FORMAT(now(),'%y-%m-%d %H:%i:%s');
--查看表结构
DESC USER1;
--新建用户 taijs123
grant SELECT,INSERT,UPDATE,DELETE on taijs.* to taijs123@localhost IDENTIFIED by "taijs123";、
--创建数据库
create database school;
--删除数据库
drop database if EXISTS school;
--将数据导入数据表
load data local infile "文件名" into table 表名;
--备份:
mysqldump [-h host] -u user -p school>school.sql;
--恢复
mysql [-h host] -u user -p school < school.sql;
转载自:http://blog.csdn.net/if_else123/article/details/1887522