


Solve the problems encountered when upgrading Docker mysql container to mysql8
mysql video tutorial This column introduces the problems encountered when upgrading the Docker mysql container to mysql8 and tells you how to effectively solve it.
Recommended (free): mysql video tutorial
Problem Restoration
The original mysql container creation command is as follows
docker run --name mysql -v /xxxx/xxx/mysqldata:/var/lib/mysql -p xxx:3306 -d mysql:laster
The data directory is mounted to /xxxx/xxx/mysqldata. The leader below asked me to upgrade mysql. I naively downloaded a mysql: 8.0.11 latest
mysql image and then execute
docker run --name mysql -v /xxxx/xxx/mysqldata:/var/lib/mysql -p xxx:3306 -d mysql:8.0.11
Create the container and mount it to the original directory: /xxxx/xxx/mysqldata
As a result, the container crashes in seconds and cannot be started at all View the log
docker logs -f -t --tail 70 mysql
The log said that the plug-in file under /xxxx/xxx/mysqldata was created in version 5.7 and could not be started in 8.0. Then I switched back to the original mysql:laster image to create the container, and it said that the files in this directory were modified by 8.0. Unable to start, it feels like this directory is so useless, the old image cannot be started, and the new one cannot be started.
So I was so stupid that I cried. Don’t directly use the new image to start the container and mount the original mysql directory. Some colleagues said that this is okay, but for What's wrong with me? Is there a problem with people?
Solution:
Use the old mysql:laster image to connect to the backup directory of /xxxx/xxx/mysqldata,Backup is too important
. Start a mysql container
Use the new mysql: 8.0.11 to start a new mysql container and mount an arbitrary directory. Then restore the old data backup to the new mysql container through other tools such as navicat. Or through the command $ docker exec some-mysql sh -c 'exec mysqldump --all-databases -uroot -p"$MYSQL_ROOT_PASSWORD"' > /some/path/on/your/host/all- databases.sql
Backup and restore.
1. If your new mysql is successfully restored and you use the navicate tool to connect, the following error is reported
Then you need to modify my.cnf of mysql File:
Add:
default_authentication_plugin=mysql_native_password
Because 8.0 uses caching_sha2_password
You can enter the container:
docker exec -it mysql /bin/bash mysql -uroot -pxxxx use mysql select Host,User,plugin from mysql.user;
See the picture below
Why do I have to modify caching_sha2_password to mysql_native_password? I don’t know. It’s just that after my 8.0.11 mysql container is started, the program interface still cannot be used normally and an error message is reported: Unable to connect to an unsupported authentication method. At this time You may need to upgrade the mysql driver of the program interface, but you are too lazy to do so, so you can only modify caching_sha2_password to mysql_native_password. As a result, you can connect normally.
3. Record some docker commands
重容器中拷贝文件到宿主机 不需要容器启动 docker cp 容器:/etc/mysql/my.cnf /home/xxx/my.cnf 将宿主机的文件拷贝容器里面的目录下 会覆盖老的文件 docker cp /home/xxx/my.cnf 容器:/etc/mysql/ 如果你特别牛逼程序中是用root来连接账号的那你可能还需要创建一个 ‘root’@'%' 的账号并修改它的权限可以远程访问,修改命令网上找
The above is the detailed content of Solve the problems encountered when upgrading Docker mysql container to mysql8. For more information, please follow other related articles on the PHP Chinese website!

MySQL index cardinality has a significant impact on query performance: 1. High cardinality index can more effectively narrow the data range and improve query efficiency; 2. Low cardinality index may lead to full table scanning and reduce query performance; 3. In joint index, high cardinality sequences should be placed in front to optimize query.

The MySQL learning path includes basic knowledge, core concepts, usage examples, and optimization techniques. 1) Understand basic concepts such as tables, rows, columns, and SQL queries. 2) Learn the definition, working principles and advantages of MySQL. 3) Master basic CRUD operations and advanced usage, such as indexes and stored procedures. 4) Familiar with common error debugging and performance optimization suggestions, such as rational use of indexes and optimization queries. Through these steps, you will have a full grasp of the use and optimization of MySQL.

MySQL's real-world applications include basic database design and complex query optimization. 1) Basic usage: used to store and manage user data, such as inserting, querying, updating and deleting user information. 2) Advanced usage: Handle complex business logic, such as order and inventory management of e-commerce platforms. 3) Performance optimization: Improve performance by rationally using indexes, partition tables and query caches.

SQL commands in MySQL can be divided into categories such as DDL, DML, DQL, DCL, etc., and are used to create, modify, delete databases and tables, insert, update, delete data, and perform complex query operations. 1. Basic usage includes CREATETABLE creation table, INSERTINTO insert data, and SELECT query data. 2. Advanced usage involves JOIN for table joins, subqueries and GROUPBY for data aggregation. 3. Common errors such as syntax errors, data type mismatch and permission problems can be debugged through syntax checking, data type conversion and permission management. 4. Performance optimization suggestions include using indexes, avoiding full table scanning, optimizing JOIN operations and using transactions to ensure data consistency.

InnoDB achieves atomicity through undolog, consistency and isolation through locking mechanism and MVCC, and persistence through redolog. 1) Atomicity: Use undolog to record the original data to ensure that the transaction can be rolled back. 2) Consistency: Ensure the data consistency through row-level locking and MVCC. 3) Isolation: Supports multiple isolation levels, and REPEATABLEREAD is used by default. 4) Persistence: Use redolog to record modifications to ensure that data is saved for a long time.

MySQL's position in databases and programming is very important. It is an open source relational database management system that is widely used in various application scenarios. 1) MySQL provides efficient data storage, organization and retrieval functions, supporting Web, mobile and enterprise-level systems. 2) It uses a client-server architecture, supports multiple storage engines and index optimization. 3) Basic usages include creating tables and inserting data, and advanced usages involve multi-table JOINs and complex queries. 4) Frequently asked questions such as SQL syntax errors and performance issues can be debugged through the EXPLAIN command and slow query log. 5) Performance optimization methods include rational use of indexes, optimized query and use of caches. Best practices include using transactions and PreparedStatemen

MySQL is suitable for small and large enterprises. 1) Small businesses can use MySQL for basic data management, such as storing customer information. 2) Large enterprises can use MySQL to process massive data and complex business logic to optimize query performance and transaction processing.

InnoDB effectively prevents phantom reading through Next-KeyLocking mechanism. 1) Next-KeyLocking combines row lock and gap lock to lock records and their gaps to prevent new records from being inserted. 2) In practical applications, by optimizing query and adjusting isolation levels, lock competition can be reduced and concurrency performance can be improved.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Dreamweaver CS6
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Zend Studio 13.0.1
Powerful PHP integrated development environment