• CentOS同时安装mysql8.0


    系统里已经有mysql5.7,但是由于特殊要求需要再安装一个8.0版本

    1、下载包
    mysql8数据库目录结构
    MySQL Binary目录:/usr/local/mysql8
    MySQL Data目录:/data/mysql8
    MySQL Backup目录:/backup/mysql8

    2、初始化

    3、配置my8.cnf
    将mysql都换成mysql8

    1. [mysqld]
    2. basedir = /usr/local/mysql8
    3. datadir = /data/mysql8
    4. socket = /tmp/mysql8.sock
    5. user = mysql8
    6. port = 3306
    7. character_set_server = utf8
    8. explicit_defaults_for_timestamp=true
    9. log_timestamps=SYSTEM
    10. server-id=1
    11. tmpdir = /tmp
    12. symbolic-links=0
    13. #数据库数据文件参数
    14. innodb_data_file_path = ibdata1:10M:autoextend
    15. innodb_file_per_table = ON
    16. #数据库内存参数
    17. key_buffer_size = 128M
    18. innodb_buffer_pool_size = 1024M
    19. #数据库线程数参数
    20. thread_cache_size = 300
    21. innodb_thread_concurrency = 4
    22. #innodb日志文件参数
    23. innodb_log_buffer_size = 16M
    24. innodb_log_file_size = 256M
    25. innodb_log_files_in_group = 3
    26. #文件描述符限制
    27. open_files_limit = 10240
    28. #数据库bin log参数
    29. #log-bin=mysql-bin
    30. #binlog-format = Row
    31. #binlog_cache_size = 4M
    32. #max_binlog_size = 256M
    33. #binlog-ignore-db=information_schema
    34. #binlog-ignore-db=mysql
    35. #binlog-ignore-db=performance_schema
    36. #binlog-ignore-db=sys
    37. #replicate_wild_do_table=test.%
    38. #replicate-do-db=test
    39. #replicate-ignore-db=mysql
    40. #log-slave-updates
    41. #slave-skip-errors=all
    42. #slave-net-timeout=60
    43. #relay-log=mysqldb02-relay-bin
    44. #master-info-repository=table
    45. #relay-log-info-repository=table
    46. #数据库表缓存参数
    47. table_open_cache = 1000
    48. table_definition_cache = 700
    49. #查询缓存参数
    50. #废弃了
    51. #query_cache_type = OFF
    52. #query_cache_size = 0
    53. #query_cache_limit = 0
    54. tmp_table_size = 512M
    55. sort_buffer_size = 2M
    56. join_buffer_size = 2M
    57. read_buffer_size = 1M
    58. read_rnd_buffer_size = 16M
    59. #数据库connect参数
    60. max_connections = 1000
    61. back_log = 100
    62. max_connect_errors = 1000
    63. max_allowed_packet = 32M
    64. #数据库慢查询日志参数
    65. slow_query_log = ON
    66. slow_query_log_file = /data/mysql8/mysqldb01-slow.log
    67. long_query_time = 10
    68. log_queries_not_using_indexes = ON
    69. secure_file_priv = /tmp
    70. # 默认使用“mysql_native_password”插件认证
    71. default_authentication_plugin=mysql_native_password
    72. [mysqld_safe]
    73. log-error = /data/mysql8/error.log
    74. pid-file = /data/mysql8/mysql.pid
    75. [mysqldump]
    76. quick
    77. max_allowed_packet = 16M
    78. [client]
    79. port=3306
    80. socket=/tmp/mysql8.sock

    4、配置mysql服务/etc/init.d/mysqld8
    将mysql都换成mysql8
    将my.cnf都换成my8.cnf(没用)

    1. [mysqld]
    2. basedir = /usr/local/mysql8
    3. datadir = /data/mysql8
    4. socket = /tmp/mysql8.sock
    5. user = mysql8
    6. port = 3306
    7. character_set_server = utf8
    8. explicit_defaults_for_timestamp=true
    9. log_timestamps=SYSTEM
    10. server-id=1
    11. tmpdir = /tmp
    12. symbolic-links=0
    13. #数据库数据文件参数
    14. innodb_data_file_path = ibdata1:10M:autoextend
    15. innodb_file_per_table = ON
    16. #数据库内存参数
    17. key_buffer_size = 128M
    18. innodb_buffer_pool_size = 1024M
    19. #数据库线程数参数
    20. thread_cache_size = 300
    21. innodb_thread_concurrency = 4
    22. #innodb日志文件参数
    23. innodb_log_buffer_size = 16M
    24. innodb_log_file_size = 256M
    25. innodb_log_files_in_group = 3
    26. #文件描述符限制
    27. open_files_limit = 10240
    28. #数据库bin log参数
    29. #log-bin=mysql-bin
    30. #binlog-format = Row
    31. #binlog_cache_size = 4M
    32. #max_binlog_size = 256M
    33. #binlog-ignore-db=information_schema
    34. #binlog-ignore-db=mysql
    35. #binlog-ignore-db=performance_schema
    36. #binlog-ignore-db=sys
    37. #replicate_wild_do_table=test.%
    38. #replicate-do-db=test
    39. #replicate-ignore-db=mysql
    40. #log-slave-updates
    41. #slave-skip-errors=all
    42. #slave-net-timeout=60
    43. #relay-log=mysqldb02-relay-bin
    44. #master-info-repository=table
    45. #relay-log-info-repository=table
    46. #数据库表缓存参数
    47. table_open_cache = 1000
    48. table_definition_cache = 700
    49. #查询缓存参数
    50. #query_cache_type = OFF
    51. #query_cache_size = 0
    52. #query_cache_limit = 0
    53. tmp_table_size = 512M
    54. sort_buffer_size = 2M
    55. join_buffer_size = 2M
    56. read_buffer_size = 1M
    57. read_rnd_buffer_size = 16M
    58. #数据库connect参数
    59. max_connections = 1000
    60. back_log = 100
    61. max_connect_errors = 1000
    62. max_allowed_packet = 32M
    63. #数据库慢查询日志参数
    64. slow_query_log = ON
    65. slow_query_log_file = /data/mysql8/mysqldb01-slow.log
    66. long_query_time = 10
    67. log_queries_not_using_indexes = ON
    68. secure_file_priv = /tmp
    69. # 默认使用“mysql_native_password”插件认证
    70. default_authentication_plugin=mysql_native_password
    71. [mysqld_safe]
    72. log-error = /data/mysql8/error.log
    73. pid-file = /data/mysql8/mysql.pid
    74. [mysqldump]
    75. quick
    76. max_allowed_packet = 16M
    77. [client]
    78. port=3306
    79. socket=/tmp/mysql8.sock

    5、编辑mysqld8.service

    1. [Unit]
    2. Description=MySQL 8.0
    3. SourcePath=/etc/init.d/mysqld8
    4. After=network.target
    5. After=syslog.target
    6. Before=shutdown.target
    7. [Service]
    8. User=mysql8
    9. Group=mysql8
    10. Type=forking
    11. ExecStart=/etc/init.d/mysqld8 start
    12. ExecStop=/etc/init.d/mysqld8 stop
    13. ExecReload=/etc/init.d/mysqld8 restart
    14. [Install]
    15. WantedBy=multi-user.target

    6、ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
    必须修改mysql初始密码

    7、导入数据

    8、更新

    1. ./mysqld --skip-grant-tables --user=mysql --upgrade=FORCE
    2. 2022-08-05T09:46:21.091800+08:00 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
    3. 2022-08-05T09:46:21.091872+08:00 0 [Warning] [MY-010143] [Server] Ignoring user change to 'mysql' because the user was set to 'mysql8' earlier on the command line
    4. 2022-08-05T09:46:21.092998+08:00 0 [Warning] [MY-010101] [Server] Insecure configuration for --secure-file-priv: Location is accessible to all OS users. Consider choosing a different directory.
    5. 2022-08-05T09:46:21.093071+08:00 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.
    6. 2022-08-05T09:46:21.093107+08:00 0 [System] [MY-010116] [Server] /usr/local/mysql8/bin/mysqld (mysqld 8.0.30) starting as process 31843
    7. 2022-08-05T09:46:21.094494+08:00 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
    8. 2022-08-05T09:46:21.115181+08:00 0 [Warning] [MY-013907] [InnoDB] Deprecated configuration parameters innodb_log_file_size and/or innodb_log_files_in_group have been used to compute innodb_redo_log_capacity=805306368. Please use innodb_redo_log_capacity instead.
    9. 2022-08-05T09:46:21.117874+08:00 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
    10. 2022-08-05T09:46:22.841355+08:00 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
    11. 2022-08-05T09:46:27.765000+08:00 4 [System] [MY-013381] [Server] Server upgrade from '80030' to '80030' started.
    12. 2022-08-05T09:47:08.509184+08:00 4 [System] [MY-013381] [Server] Server upgrade from '80030' to '80030' completed.
    13. 2022-08-05T09:47:08.928553+08:00 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
    14. 2022-08-05T09:47:08.928604+08:00 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
    15. 2022-08-05T09:47:08.951677+08:00 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: /tmp/mysqlx.sock
    16. 2022-08-05T09:47:08.951727+08:00 0 [System] [MY-010931] [Server] /usr/local/mysql8/bin/mysqld: ready for connections. Version: '8.0.30' socket: '/tmp/mysql8.sock' port: 0 MySQL Community Server - GPL.

    9、问题
    一个CentOS上既有mysql5.7,又有mysql8.0
    配置文件需要改名my.cnf、my.cnf.57
    端口都是3306,所以只能起一个,如需用另一个要改名配置文件切换

  • 相关阅读:
    Visio——对齐方法的规则
    企业电子杂志如何制作与分享
    Amazon Lightsail——兼具亚马逊云科技的强大功能与 VPS 的简易性
    【附源码】Python计算机毕业设计图书销售系统设计
    (c++)类和对象中篇
    curl 工具的使用
    机械专业学子的芯片封装仿真“逆袭之路”
    Java:本地文件通过表单参数接口发送后大小变成0
    剑指offer 14. 二进制中1的个数
    ChinaSoft 论坛巡礼|面向云游戏的云侧软件技术论坛
  • 原文地址:https://blog.csdn.net/csj50/article/details/126171950