分类 技术相关 下的文章

iOS uitextfield长度限制

[textUsername addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];

- (void)textFieldDidChange:(UITextField *)textField

{

    if (textField == textUsername) {

        if (textField.text.length > 9) {

            textField.text = [textField.text substringToIndex:9];

        }

    }

}

/*

  • unicode编码转中文
    */

public static String decodeUnicode(String str) {
Pattern pattern = Pattern.compile("(\\u(\p{XDigit}{4}))");
Matcher matcher = pattern.matcher(str);
char ch;
while (matcher.find()) {

  ch = (char) Integer.parseInt(matcher.group(2), 16);
  str = str.replace(matcher.group(1), ch + "");

}
return str;
}

1.Copy整个Mysql目录及数据文件到另一台电脑,路径跟原安装路径一致

2.环境变量添加path路径 指定到mysql 的bin目录,也可设置HOME,如下方:

新增系统变量MYSQL_HOME:安装目录
在PATH变量的最后面添加: ;%MYSQL_HOME%\bin(注意前面的;)

3.根据需要调整配置文件

4.注册服务

cmd 输入命令: mysqld --install mysql

5.启动服务 net start mysql

mysql迁移

Navicat连接后,发现原数据库都在,完美迁移。

Notes
For Connector/J 8.0.12 and earlier: In order to use the utf8mb4 character set for the connection, the server MUST be configured with character_set_server=utf8mb4; if that is not the case, when UTF-8 is used for characterEncoding in the connection string, it will map to the MySQL character set name utf8, which is an alias for utf8mb3.

For Connector/J 8.0.13 and later:

When UTF-8 is used for characterEncoding in the connection string, it maps to the MySQL character set name utf8mb4.

If the connection option connectionCollation is also set alongside characterEncoding and is incompatible with it, characterEncoding will be overridden with the encoding corresponding to connectionCollation.

Because there is no Java-style character set name for utfmb3 that you can use with the connection option charaterEncoding, the only way to use utf8mb3 as your connection character set is to use a utf8mb3 collation (for example, utf8_general_ci) for the connection option connectionCollation, which forces a utf8mb3 character set to be used, as explained in the last bullet.

官方手册链接:
https://dev.mysql.com/doc/connectors/en/connector-j-reference-charsets.html

提示
mysql-connector-java 版本在8.0.12之前的,包括8.0.12,服务端必须设置character_set_server=utf8mb4;如果不是的话,就算设置了characterEncoding=UTF-8,照样会被设置为MYSQL的 utf8字符集,也就是utf8mb3。

对于8.0.13和以后的版本,如果设置了characterEncoding=UTF-8,他会映射到MYSQL的utf8mb4字符集。

如果connectionCollation 也和characterEncoding一起设置了,但是不兼容,characterEncoding会被connectionCollation的设置覆盖掉。

由于没有Java-Style的utfmb3对应的字符集名称可以用在connection选项charaterEncoding上,唯一的设置utf8mb3的方式就是在连接选项设置utf8mb3 collation(例如utf8_general_ci),这会强制使用utf8mb3字符集,正如上文所述。

查看mysql字符集

show variables like 'char%'; show variables like 'collation%';

免责声明
本博客部分内容来自于互联网,不代表作者的观点和立场,如若侵犯到您的权益,请联系238611804@139.com。我们会在24小时内进行删除。