"<span style=""font-family:宋体, 'Lucida Grande', 'Lucida Sans', Verdana, Arial, sans-serif;font-size:13px;line-height:18.2px;background-color:#FFFFFF;"">在mint18上sudo apt-get install mysql-server
<span style=""font-family:宋体, 'Lucida Grande', 'Lucida Sans', Verdana, Arial, sans-serif;font-size:13px;line-height:18.2px;background-color:#FFFFFF;"">
<span style=""font-family:宋体, 'Lucida Grande', 'Lucida Sans', Verdana, Arial, sans-serif;font-size:13px;line-height:18.2px;background-color:#FFFFFF;"">然后默认安装的5.7版本,很多教程说5.7版本会在/root/目录下有个 隐藏文件 .mysql_secret
<span style=""font-family:宋体, 'Lucida Grande', 'Lucida Sans', Verdana, Arial, sans-serif;font-size:13px;line-height:18.2px;background-color:#FFFFFF;"">
<span style=""font-family:宋体, 'Lucida Grande', 'Lucida Sans', Verdana, Arial, sans-serif;font-size:13px;line-height:18.2px;background-color:#FFFFFF;"">然而我切刀root目录 <span style=""font-family:宋体, 'Lucida Grande', 'Lucida Sans', Verdana, Arial, sans-serif;font-size:13px;line-height:18.2px;background-color:#FFFFFF;"">并没有找到,求教初始的root密码从哪里找?
<span style=""font-family:宋体, 'Lucida Grande', 'Lucida Sans', Verdana, Arial, sans-serif;font-size:13px;line-height:18.2px;background-color:#FFFFFF;"">
<span style=""font-family:宋体, 'Lucida Grande', 'Lucida Sans', Verdana, Arial, sans-serif;font-size:13px;line-height:18.2px;background-color:#FFFFFF;"">附带:安装过程也没有提示设置root用户密码的地方 ,那是 <span style=""font-family:宋体, 'Lucida Grande', 'Lucida Sans', Verdana, Arial, sans-serif;font-size:13px;line-height:18.2px;background-color:#FFFFFF;"">mysql5.6的安装方式"
"alter table test_str modify column str_desc varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;######
JadePool轻松修改MySQL数据库的字符集
import cn.jadepool.sql.Field;
import cn.jadepool.sql.Jade;
import cn.jadepool.sql.Table;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* 修改MySQL数据库字符集
*
* @author 上海皆普信息科技有限公司 胡开明
*/
public class ChangeCharset {
//ALTER SCHEMA `jadepool_dictionary` DEFAULT COLLATE utf8mb4_unicode_ci ;
//ALTER TABLE `jadepool_dictionary`.`dic_emoji` COLLATE = utf8mb4_unicode_ci ;
//ALTER TABLE `jadepool_dictionary`.`dic_emoji` CHANGE COLUMN `code` `code` VARCHAR(32) CHARACTER SET 'utf8mb4' ;
//ALTER TABLE `fwfw_jiben`.`fwfw_dw` CHARACTER SET = utf8mb4 , COLLATE = DEFAULT ,CHANGE COLUMN `jianjie` `jianjie` TEXT CHARACTER SET 'utf8mb4' ;
public static void main(String[] args) {
Jade j = new Jade(getMySQLCon());
String schema = j.getDb().getCatalog();//数据库的名称
j.execute("ALTER SCHEMA `" + schema + "` DEFAULT COLLATE utf8mb4_unicode_ci");
String[] tables = j.getDb().getTableNames();
for (String tableName : tables) {
j.execute("ALTER TABLE " + tableName + " COLLATE = utf8mb4_unicode_ci ");
Table table = j.getDb().getTable(tableName);
String[] fields = table.getFields();
for (String fieldName : fields) {
Field field = j.getDb().getField(tableName, fieldName);
String typeName = field.getTypeName();
String size = field.getSize();
if ("text".equals(typeName)) {
j.execute("ALTER TABLE " + tableName + " CHARACTER SET = utf8mb4 , COLLATE = DEFAULT ,CHANGE COLUMN `"+fieldName+"` `"+fieldName+"` TEXT
CHARACTER SET 'utf8mb4' ");
}
if ("varchar".equals(typeName)) {
j.execute("ALTER TABLE " + tableName + " CHANGE COLUMN `"+fieldName+"` `"+fieldName+"` VARCHAR("+size+") CHARACTER SET 'utf8mb4' ");
}
}
}
j.commit();
}
public static synchronized Connection getMySQLCon() {
Connection con = null;
String url = "jdbc:mysql://localhost:3306/db_name_xxxxxx?
useOldAliasMetadataBehavior=true&zeroDateTimeBehavior=convertToNull";//useUnicode=true&characterEncoding=utf8mb4&
String userName = "xxxxxx";
String password = "xxxxxx";
try {
Class.forName("com.mysql.jdbc.Driver");//com.mysql.jdbc.Driver
con = DriverManager.getConnection(url, userName, password);
} catch (ClassNotFoundException ex) {
Logger.getLogger(ChangeCharset.class.getName()).log(Level.SEVERE, null, ex);
} catch (SQLException ex) {
Logger.getLogger(ChangeCharset.class.getName()).log(Level.SEVERE, null, ex);
}
return con;
}
}
" ![image.png](https://ucc.alicdn.com/pic/developer-ecology/041af1e8d46943cb9a51dfb1b8c225a4.png)
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。