常見問題--MySQL

來源:互聯網
上載者:User

標籤:com   jdbc   ctr   ice   sum   常用   微軟   ack   padding   

group by相關“only_full_group_by” SQL_MODE是預設開啟的,開啟後只能擷取受group by影響的欄位,而對於非group by的資訊需要通過any_value(name)函數擷取(mysql 5.7之後)
ibatis annotations 註解方式返回剛插入的自增長主鍵ID的值
  @Insert("insert into Product(title, image, price, detail, summary, seller) values(#{title},#{image},#{price},#{detail},#{summary},#{seller})")  @Options(useGeneratedKeys=true, keyProperty="id")//添加該行,product中的id將被自動添加public Integer insertProduct(Product product);

亂碼問題

tomcat造成的亂碼,在server.xml中設定:

<Connector URIEncoding="UTF-8" connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443" useBodyEncodingForURI="true" />


串連資料庫的URL中加入編碼格式,如:

jdbc.url= jdbc:mysql://127.0.0.1:3306/electronic-business?useUnicode=true&characterEncoding=UTF-8

資料庫設定:

mysql> SET character_set_client=‘gbk‘;

mysql> SET character_set_connection=‘gbk‘

mysql> SET character_set_results=‘gbk‘

mysql> SET character_set_database=‘gbk‘;

mysql> SET character_set_server=‘gbk‘

mysql> SET character_set_results=‘gbk‘

改成gbk或者utf-8都可以

常用相關命令:查看資料庫編碼格式show variables like ‘character_set_%‘;查看資料庫中的表的建立show create table tablename;設定資料庫編碼格式set names= ‘gbk‘;或者在mysql命令列下輸入 \s查看mysql的字元集的方式
blob格式引起的亂碼:blob讀出來的是ISO-8859-1編碼,你需要轉換為GBK編碼才可以Java codeString blob =...blob = new String(blob.getBytes("iso-885901"),"GBK");或者存取大文本的時候用mediumtext而不用blob
CentOS 7 通過yum安裝MySQL 5.71.下載YUM庫shell > wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm2.安裝YUM庫shell > yum localinstall -y mysql57-community-release-el7-7.noarch.rpm3.安裝資料庫shell > yum install -y mysql-community-server4.啟動MySQL服務shell > systemctl start mysqld.service

常見問題--MySQL

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.