MySql篇
1.下载并安装Mysql
(1)下载地址
MySQL-8.0下载地址
(2)Mysql配置
1.home目录下命令行执行:vi .bash_profile来配置MySql绝对路径
2.MySql配置如下:
Setting PATH for MySql 8.0.15
# Setting PATH for Python 3.7
#The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
#########################################
#mysql 环境变量如下
export PATH=${PATH}:/usr/local/mysql/bin
export PATH
#########################################
alias python="/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7"
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
fi
配置完毕后,保存并退出.
命令行执行:
#mysql -u root -p #使用root权限登陆mysql
#create user 'diting'@'localhost' identified by 'diting'; #使用root创建mysql用户diting密码为diting
#CREATE DATABASE diting; #创建数据库diting
#show databases; #查看root创建的数据库中包含diting
#grant all privileges on diting.* to 'diting'@'localhost'; #root授权给用户diting对数据库diting操作的所有权限
#quit #退出root权限
#mysql -u diting -p #使用用户diting登陆mysql
#执行建表语句:
create table dt_image
(
id bigint auto_increment
primary key,
image_name varchar(200) null,
image_path varchar(500) null,
create_time timestamp null,
constraint dt_image_image_name_uindex
unique (image_name)
);
create table dt_user
(
id bigint auto_increment
primary key,
user_account varchar(50) not null,
user_password varchar(50) not null,
create_time timestamp not null,
user_emails varchar(50) null,
user_roles varchar(50) null,
user_token varchar(500) not null,
constraint dt_user_user_account_uindex
unique (user_account)
);
#Mysql命令行所有命令执行完毕
F&Q&A
1.mysql对大小写敏感,输入SQL语句时注意大小写;
2.在为数据库谛听创建table时,注意一定记得切换为用户diting来创建,否则需要root授权.
3.在命令行执行建表语句时,SQL语句可能因为语法问题而无法执行,推荐使用IDEA来建表,很简单这里不在赘述.
标签:权限,varchar,mysql,diting,user,MySQL,null,root
来源: https://www.cnblogs.com/Eillot/p/10455904.html