1. Ubuntu服務(wù)器時(shí)間和tomcat時(shí)間不一致
今天碰到一個(gè)問題枪萄,就是服務(wù)器的時(shí)間和tomcat的時(shí)間不一致隐岛,導(dǎo)致數(shù)據(jù)庫時(shí)間都是正確的,但是從數(shù)據(jù)庫獲取的時(shí)間出來顯示的時(shí)候就出問題了瓷翻,然后查看tomcat的logs得知服務(wù)器的時(shí)間跟電腦上的時(shí)間不一樣
date -R // 首先查看服務(wù)器的時(shí)間
tzselect // 設(shè)置服務(wù)器的時(shí)間
但是這個(gè)方法不是正確, 使用下面這個(gè)方法
dpkg-reconfigure tzdata // 選上海
然后重啟服務(wù)器聚凹,在請求數(shù)據(jù),正確齐帚。
MySQL常用操作
# 常用命令
mysql -uroot -p 回車 輸入密碼 # 鏈接數(shù)據(jù)庫
status # 查看數(shù)據(jù)庫狀態(tài)
show databases # 顯示所有數(shù)據(jù)庫
use database # 切換數(shù)據(jù)庫
show tables # 顯示數(shù)據(jù)庫中的所有數(shù)據(jù)表
show create table table_name # 顯示數(shù)據(jù)表創(chuàng)建時(shí)的全部信息
show create view view_name # 視圖
desc table_name # 查看數(shù)據(jù)表的屬性信息以及個(gè)字段的描述
# 常用的數(shù)據(jù)庫SQL語句
create database database_name # 創(chuàng)建數(shù)據(jù)庫
# 創(chuàng)建表
create table student(
id int unsigned auto_increment,
name varchar(30) not null default '',
age tinyint unsigned not null default 0,
content text not null default '',
primary key(id),
key index_age(age)
)engine=innodb default charset=utf8;
#添加一個(gè)字段
alter table student add column sort tinyint not null default 0 after content;
alter table student column is_del tiny int not null default 0;
# 刪除字段
alter table student drop column age;
alter table student drop age;
# 修改字段名和字段類型
alter table student change sort sort_desc tinyint not null default 1;
# 修改表明
alter table studnet rename to students;
# 修改表引擎
alter table student engine=myisam;
# 索引相關(guān)
# 添加主鍵
alter table student add primary key (id);
# 添加唯一索引
alter table student add unique(name)
# 添加INDEX
alter table student add index index_name ('name');
# 全文索引
alter table student add FULLTEXT ('content');
# 添加多列索引
alter table student add index index_name ('age', 'name');
# 查看索引
show index from studnet;
https://www.baidu.com/home/news/data/newspage?nid=11256019309637025310&n_type=0&p_from=1