系统里已经有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
- [mysqld]
- basedir = /usr/local/mysql8
- datadir = /data/mysql8
- socket = /tmp/mysql8.sock
- user = mysql8
- port = 3306
- character_set_server = utf8
- explicit_defaults_for_timestamp=true
- log_timestamps=SYSTEM
- server-id=1
- tmpdir = /tmp
- symbolic-links=0
-
- #数据库数据文件参数
-
- innodb_data_file_path = ibdata1:10M:autoextend
- innodb_file_per_table = ON
-
- #数据库内存参数
-
- key_buffer_size = 128M
- innodb_buffer_pool_size = 1024M
-
- #数据库线程数参数
-
- thread_cache_size = 300
- innodb_thread_concurrency = 4
-
- #innodb日志文件参数
-
- innodb_log_buffer_size = 16M
- innodb_log_file_size = 256M
- innodb_log_files_in_group = 3
-
- #文件描述符限制
-
- open_files_limit = 10240
-
- #数据库bin log参数
-
- #log-bin=mysql-bin
- #binlog-format = Row
- #binlog_cache_size = 4M
- #max_binlog_size = 256M
- #binlog-ignore-db=information_schema
- #binlog-ignore-db=mysql
- #binlog-ignore-db=performance_schema
- #binlog-ignore-db=sys
- #replicate_wild_do_table=test.%
- #replicate-do-db=test
- #replicate-ignore-db=mysql
- #log-slave-updates
- #slave-skip-errors=all
- #slave-net-timeout=60
- #relay-log=mysqldb02-relay-bin
- #master-info-repository=table
- #relay-log-info-repository=table
-
- #数据库表缓存参数
-
- table_open_cache = 1000
- table_definition_cache = 700
-
- #查询缓存参数
- #废弃了
- #query_cache_type = OFF
- #query_cache_size = 0
- #query_cache_limit = 0
-
- tmp_table_size = 512M
- sort_buffer_size = 2M
- join_buffer_size = 2M
- read_buffer_size = 1M
- read_rnd_buffer_size = 16M
-
- #数据库connect参数
-
- max_connections = 1000
- back_log = 100
- max_connect_errors = 1000
- max_allowed_packet = 32M
-
- #数据库慢查询日志参数
-
- slow_query_log = ON
- slow_query_log_file = /data/mysql8/mysqldb01-slow.log
- long_query_time = 10
- log_queries_not_using_indexes = ON
-
- secure_file_priv = /tmp
-
- # 默认使用“mysql_native_password”插件认证
- default_authentication_plugin=mysql_native_password
-
- [mysqld_safe]
- log-error = /data/mysql8/error.log
- pid-file = /data/mysql8/mysql.pid
-
- [mysqldump]
- quick
- max_allowed_packet = 16M
-
- [client]
- port=3306
- socket=/tmp/mysql8.sock
4、配置mysql服务/etc/init.d/mysqld8
将mysql都换成mysql8
将my.cnf都换成my8.cnf(没用)
- [mysqld]
- basedir = /usr/local/mysql8
- datadir = /data/mysql8
- socket = /tmp/mysql8.sock
- user = mysql8
- port = 3306
- character_set_server = utf8
- explicit_defaults_for_timestamp=true
- log_timestamps=SYSTEM
- server-id=1
- tmpdir = /tmp
- symbolic-links=0
-
- #数据库数据文件参数
-
- innodb_data_file_path = ibdata1:10M:autoextend
- innodb_file_per_table = ON
-
- #数据库内存参数
-
- key_buffer_size = 128M
- innodb_buffer_pool_size = 1024M
-
- #数据库线程数参数
-
- thread_cache_size = 300
- innodb_thread_concurrency = 4
-
- #innodb日志文件参数
-
- innodb_log_buffer_size = 16M
- innodb_log_file_size = 256M
- innodb_log_files_in_group = 3
-
- #文件描述符限制
-
- open_files_limit = 10240
-
- #数据库bin log参数
-
- #log-bin=mysql-bin
- #binlog-format = Row
- #binlog_cache_size = 4M
- #max_binlog_size = 256M
- #binlog-ignore-db=information_schema
- #binlog-ignore-db=mysql
- #binlog-ignore-db=performance_schema
- #binlog-ignore-db=sys
- #replicate_wild_do_table=test.%
- #replicate-do-db=test
- #replicate-ignore-db=mysql
- #log-slave-updates
- #slave-skip-errors=all
- #slave-net-timeout=60
- #relay-log=mysqldb02-relay-bin
- #master-info-repository=table
- #relay-log-info-repository=table
-
- #数据库表缓存参数
-
- table_open_cache = 1000
- table_definition_cache = 700
-
- #查询缓存参数
-
- #query_cache_type = OFF
- #query_cache_size = 0
- #query_cache_limit = 0
-
- tmp_table_size = 512M
- sort_buffer_size = 2M
- join_buffer_size = 2M
- read_buffer_size = 1M
- read_rnd_buffer_size = 16M
-
- #数据库connect参数
-
- max_connections = 1000
- back_log = 100
- max_connect_errors = 1000
- max_allowed_packet = 32M
-
- #数据库慢查询日志参数
-
- slow_query_log = ON
- slow_query_log_file = /data/mysql8/mysqldb01-slow.log
- long_query_time = 10
- log_queries_not_using_indexes = ON
-
- secure_file_priv = /tmp
-
- # 默认使用“mysql_native_password”插件认证
- default_authentication_plugin=mysql_native_password
-
- [mysqld_safe]
- log-error = /data/mysql8/error.log
- pid-file = /data/mysql8/mysql.pid
-
- [mysqldump]
- quick
- max_allowed_packet = 16M
-
- [client]
- port=3306
- socket=/tmp/mysql8.sock
5、编辑mysqld8.service
- [Unit]
- Description=MySQL 8.0
- SourcePath=/etc/init.d/mysqld8
- After=network.target
- After=syslog.target
- Before=shutdown.target
-
- [Service]
- User=mysql8
- Group=mysql8
- Type=forking
- ExecStart=/etc/init.d/mysqld8 start
- ExecStop=/etc/init.d/mysqld8 stop
- ExecReload=/etc/init.d/mysqld8 restart
-
- [Install]
- WantedBy=multi-user.target
6、ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
必须修改mysql初始密码
7、导入数据
8、更新
- ./mysqld --skip-grant-tables --user=mysql --upgrade=FORCE
- 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.
- 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
- 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.
- 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.
- 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
- 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.
- 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.
- 2022-08-05T09:46:21.117874+08:00 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
- 2022-08-05T09:46:22.841355+08:00 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
- 2022-08-05T09:46:27.765000+08:00 4 [System] [MY-013381] [Server] Server upgrade from '80030' to '80030' started.
- 2022-08-05T09:47:08.509184+08:00 4 [System] [MY-013381] [Server] Server upgrade from '80030' to '80030' completed.
- 2022-08-05T09:47:08.928553+08:00 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
- 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.
- 2022-08-05T09:47:08.951677+08:00 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: /tmp/mysqlx.sock
- 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,所以只能起一个,如需用另一个要改名配置文件切换