• MySQL


    1.命令
    1.1 显示所有数据库
    show databases;
    1.2 选择数据库
    use 数据库名
    1.3 显示所有表
    show tables;
    1.4 刷脚本
    mysql>source path+filename.sql

    DELIMITER //
    CREATE PROCEDURE P_REMOVE_STUDENT(IN ids VARCHAR(100),OUT result int)
    BEGIN
    DECLARE v_P int;# 标识ids字符串中逗号的位置
    DECLARE v_Id int;# 单个id
    SET v_P = INSTR(ids,",");
    IF v_P = 0 THEN
    DELETE FROM T_STUDENT WHERE ID=ids;
    #SELECT ids;
    ELSE
    WHILE v_P > 0 DO
    # 从第一个字符开始到逗号位置截取,但不包含逗号
    SET v_Id = SUBSTRING(ids FROM 1 FOR v_P-1);

    # 截取剩下的字符,但不包含逗号
    SET ids = SUBSTRING(ids FROM v_P+1);
    #SELECT v_Id,ids;
    DELETE FROM T_STUDENT WHERE ID=v_Id;

    # 获取剩下的字符中逗号的位置,以便于下一步的截取
    SET v_P = INSTR(ids,",");
    END WHILE;

    # 循环结束后,ids中可能还有正常的数据,此时要处理
    IF LENGTH(ids) > 0 THEN
    DELETE FROM T_STUDENT WHERE ID=ids;
    END IF;
    END IF;

    # 设置执行结果为成功
    SET result = 1;
    END
    //
    DELIMITER ;

    dos下无法插入汉字:****************************
    dos下mysql内置编译是使用gbk

    所以即使你把所有的编码格式都改为utf-8

    仍然需要增加一个操作,在所选数据库

    使用 set names gbk; 然后再输入中文 就OK了

    数据库保存的仍然为utf-8

    mysql修改列名
    alter table t_clazz change id clazz_id int;


    远程访问数据库配置
    /etc/mysql/mysql.conf.d$ sudo vi mysqld.cnf
    #bind-address = 127.0.0.1 注掉

    grant all privileges on *.* to 'root'@'%' identified by '123456';  #root为远程登录用户,123456为远程登录用户的密码
    flush privileges;

    比如:

    grant all privileges on match_info.* to 'ychs'@'192.168.1.120' identified by 'Ychs_2018' with grant option;

    service mysql restart 重启服务


    显示数据库编码
    SHOW VARIABLES LIKE 'character%'
    mysql> SHOW VARIABLES LIKE 'character%';
    +--------------------------+----------------------------+
    | Variable_name | Value |
    +--------------------------+----------------------------+
    | character_set_client | utf8 |
    | character_set_connection | utf8 |
    | character_set_database | latin1 |
    | character_set_filesystem | binary |
    | character_set_results | utf8 |
    | character_set_server | latin1 |
    | character_set_system | utf8 |
    | character_sets_dir | /usr/share/mysql/charsets/ |
    +--------------------------+----------------------------+
    8 rows in set (0.00 sec)

    修改编码:
    [mysqld]

    修改用户密码:---------------------------------------------------------------------------------------

    ubuntu@VM-0-13-ubuntu:~/match$ mysqladmin -uxxx -pxxxx password xxxxx

    xxx是用户名,xxxx是原密码,xxxxx是新密码

    set password for 用户名@localhost = password('新密码')

    查询报错---------------------------------------------------------------------------------------------------

    mysql有些服务器对于count这样的统计会报错,是因为强制分组,和一个变量有关系,要修改配置文件

    ubuntu@VM-0-13-ubuntu:/etc/mysql/mysql.conf.d$ 

     sudo vi mysqld.cnf 

    sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'

    保存后,重启服务

  • 相关阅读:
    sphinx实时索引和高亮显示
    打开页面就进行下载的一种方法
    mysql开启慢查询日志以及查看(转载自网络)
    Best MVC Practices(最优的MVC布局)
    nginx虚拟机配置(支持php)
    一个简单大方的赞后+1,踩后-1js动画效果
    如何创建ajax对象?
    psd图片到html
    小知识
    sass入门
  • 原文地址:https://www.cnblogs.com/java-ty/p/11308707.html
Copyright © 2020-2023  润新知