服務器docker安裝以自定義配置文件my.cnf部署mysql

一、下載mysql

命令:docker pull mysql,自動拉取latest版本,下載速度過慢的自行百度更換鏡像源

二、創建並啓動mysql容器

後邊我們再以配置文件啓動
命令:docker run -d --name mysql01 -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql:latest
本地用Navicat for MySQL連接服務器mysql,報1251錯誤的話(mysql8.0+會出現),按照以下方式解決:

# 1、進入容器
docker exec -it mysql01 bash
# 2、登錄mysql
mysql -u root -p
# 輸入密碼進入
# 更新密碼
alter user 'root'@'%' identified with mysql_native_password by '123456';

出現Query OK,0 rows affected則成功
然後再次連接即可

三、springboot使用docker下mysql8.0+出錯

  • [Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column ‘information_schema.PROFILING.SEQ’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with
    sql_mode=only_full_group_by
  • 需要修改配置文件sql_mode字段
    解決方案請看筆者另外一篇文章:解決錯誤並以本地配置文件映射容器進行創建,裏面的內容直接完成本次博客主題,謝謝
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章