mysql学习笔记

mysql

install

windows

mysql installer can finish almost all of the things of configuring and installing. There have two programs should be noticed,MySQL Server which is the main application to deploy your database or something else. MySQL WorkBench is a program graphical to control your database, server etc. Remember when your configure the MySQL Server, the user should act the actual effects, such as Admin or Database manager.

connect

  • When u connect to the server.

create databese xxx; (ctrl+enter execute current line)

usage

  • create table for the database
create table `database's name`.`table's name`(
    command
)

TIPS

  • tips:when u write your page with idea,and indent the row too behind,it will be automaticaliy code snippet

  • FUNCTIONPROCEDURE,除了function只能返回一个函数外,其他基本一样

  • while和创建过程

Created with Raphaël 2.2.0 create function name (params) returns type charset name; begin declare name type; while condition do end while end statement yes no
  • repeat
repeat
    statement
until condition
end repeat
  • if-else
if condition then
    statement
else
    statement
end if

密码设置

忘记密码

  • 首先找到.cnf配置文件,有很多个,按优先次序寻找即可。

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Tvau9HWc-1604822322783)(/cnf.png)]

  • 然后打开cnf文件在里面添加以下代码
[mysqld]
skip-grant-tables

加入这段语句后执行/etc/init.d/mysql restart重启mysql服务后登陆mysql时将不需要密码,即执行mysql -u root -p然后回车即可登录

修改密码

执行以下语句更改密码update mysql.user set authentification_string=password('xxxxxx') where user='root' and host='localhost'

然后执行flush privileges即可更改密码

当更改完密码后记得将前面设置的内容删除,不然登录仍然是不用密码的

修改登录权限

赋予所有人登录权限,以root+密码的形式登录

grant all privileges on *.* to 'root'@'%' INDETIFIED BY 'password' WITH GRANT OPTION;
flush privileges;

sql

time_format()

参考这里

# 分钟是%i 具体规则上网百度吧 
select DATE_FORMAT(time_column,"%Y %m %d %h %i %s")
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值