常用命令:
create database db_users;
drop database db_users;
show databases;
use db_users;
show tables from db_users;
create table tb_users(
id int(8) auto_increment primary key,
username varchar(30) not null);
alter tb_users add password varchar(30) not null,
add createtime datetime;
desc tb_users;
alter table btcklines1 add primary key(open_time);
rename table btcklines1 to btcklines;
truncate ethklines; 清空表
select count(*) from ethklines; 表行数
show tables from db_xxx like 'tablename'; 查询表是否存在
select bin_to_uuid(id) from xxxtable; 读取为uuid字符
select user_api.*, users.email from user_api inner join users on user_api.uuid=bin_to_uuid(users.id) where user_api.exchange=xxx; 表内联,可指定选取各表字段,where 条件放最后
问题解决:
1.Ubuntu 运行 .jar 访问 mysql :access denied for user 'root'@'localhost'
原因无法获取root 权限,解决办法创建新用户并授权。
create user 'username'@'localhost' identified by 'password';
grant all privileges on *.* to 'username'@'localhost';
username:自己想要创建的用户名
localhost:在本地登录用户,如果想让该用户可以远程主机登陆,可以使用通配符%,
password:自己想要设置的密码
2.win10 mysql服务无法启动
打开服务修改为本地系统账户登录