mysql-8-trouble-shot

笔者安装使用mysql 8 踩坑填坑实录 :(

停止和启动mysql服务 (Windows 10 1803

  • 启动
1
C:\> "C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld"
  • 停止
1
C:\> "C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqladmin" -u root shutdown

停止没有问题
在启动服务这里报出

1
2
3
4
5
6
7
mysqld: Can't change dir to 'C:\Program Files\MySQL\MySQL Server 8.0\data\' (OS errno 2 - No such file or directory)
2018-11-30T08:54:46.184667Z 0 [System] [MY-010116] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe (mysqld 8.0.13) starting as process 10616
2018-11-30T08:54:46.188074Z 0 [Warning] [MY-010091] [Server] Can't create test file C:\Program Files\MySQL\MySQL Server 8.0\data\unico.lower-test
2018-11-30T08:54:46.188146Z 0 [Warning] [MY-010091] [Server] Can't create test file C:\Program Files\MySQL\MySQL Server 8.0\data\unico.lower-test
2018-11-30T08:54:46.188613Z 0 [ERROR] [MY-010172] [Server] failed to set datadir to C:\Program Files\MySQL\MySQL Server 8.0\data\
2018-11-30T08:54:46.196222Z 0 [ERROR] [MY-010119] [Server] Aborting
2018-11-30T08:54:46.197294Z 0 [System] [MY-010910] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe: Shutdown complete (mysqld 8.0.13) MySQL Community Server - GPL.

问题在于使用MySQL 8.0 installer on Windows时把 \MySQL\MySQL Server 8.0\data\ 数据文件夹创建在了 C:\ProgramData\MySQL\MySQL Server 8.0\Data

  • 解决方法:

使用MySQL Workbench 8.0 CE面板进行启动 停止操作

导出/导入数据

此过程从windows mysql 8.0迁移centos 7 mysql 5.5

  • 导出数据
  • mysql5.5 导入mysql 8.0导出的数据
1
# mysql -u root -p mydb < /home/xxx/sql_file.sql

报错 ERROR 1273 (HY000) at line 25: Unknown collation: 'utf8mb4_0900_ai_ci'

这是由于8.0中的字符编码使用了比utf8更高级的utf8mb4所以需要手动打开sql文件 将文件中的 utf8 手动改为 utf8mb4 而 utf8mb4_0900_ai_ci 改为 utf8_general_ci

方案来源点这里

改完后再复制到linux中导入便可以了

待续..