In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to install mysql5.6 in docker under ubuntu, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
1. Install mysql5.6
Docker run mysql:5.6
When all the projects are installed by Download complet
5.6: Pulling from library/mysql10a267c67f42: Pull complete c2dcc7bb2a88: Pull complete 17e7a0445698: Pull complete 9a61839a176f: Pull complete d4657fda01d9: Pull complete c5278a445e5d: Pull complete 197c0b76f238: Pull complete f54c5432bac4: Pull complete c26b15abee8a: Pull complete 80dbe6022c18: Pull complete 435678c09612: Pull complete Digest: sha256:84372107beb1de34bd4673049ea61bc35f374a2b4f19fd5a3abd4d0a2a50b715Status: Downloaded newer image for mysql:5.6error: database is uninitialized and password option is not specified You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD
two。 Use a local account to create a folder to map the configuration file of mysql in docker
Continue to create three folders: conf, data and logs
My configuration is as follows
Val@val-linux:~/docker/mysql1 $pwd/home/val/docker/mysql1val@val-linux:~/docker/mysql1 $lsconf data logs
3. Create a mysql container
Switch to the root account and enter the mysql1 folder you just created.
Root@val-linux:/home/val# cd / home/val/docker/mysql1/root@val-linux:/home/val/docker/mysql1#
Create and start the container
Docker run-p 33061PWD/logs:/logs 3306-- name mysql1-v $PWD/conf:/etc/mysql-v $PWD/logs:/logs-v $PWD/data:/mysql_data-e MYSQL_ROOT_PASSWORD=123456-d mysql:5.61 use local port 33061 mapping port 3306 of docker to name the container mysql1 local / home/val/docker/mysql1/conf mapping mysql conf local / home/val/docker/mysql1/logs mapping mysql logs local / home/val/docker/mysql1/data mapping mysql mysql_data
Set the password for root to 123456
4. Start the mysql container
Docker start mysql11
5. Enter the bash of mysql
Docker exec-it mysql1 env LANG=C.UTF-8 bash
Among them, env LANG=C.UTF-8 bash makes docker command line support Chinese
6. Copy Profil
Cp / usr/my.cnf / etc/mysql/my.cnf
7. Log in to mysql
Mysql-u root-p
Enter the password to enter
8. View mysql encodings
Mysql > show variables like'% character%' +-- +-- + | Variable_name | Value | + -+ | character_set_client | latin1 | | character_set_connection | latin1 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | latin1 | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | / usr/share/mysql/charsets/ | +-- -+-- + 8 rows in set (0.01sec)
Found that it is not utf-8 coding.
9. Modify mysql coding
Exit mysql, exit docker
Mysql > exitByeroot@8b83a30acbf8:/# exitexitroot@val-linux:/home/val/docker/mysql1#
Modify my.cnf configuration file
Root@val-linux:/home/val/docker/mysql1# vim conf/my.cnf
Press I to enter edit mode
Join
[client] default-character-set=utf8 [mysql] default-character-set=utf8 [mysqld] character-set-server=utf8 1esc: wq! Save exit
10. Restart the mysql of docker to check the code again
Root@val-linux:/home/val/docker/mysql1# docker stop mysql1mysql1root@val-linux:/home/val/docker/mysql1# docker start mysql1mysql1root@val-linux:/home/val/docker/mysql1# docker exec-it mysql1 env LANG=C.UTF-8 bashroot@8b83a30acbf8:/# mysql-u root-pEnter password: Welcome to the MySQL monitor. Commands end with; or\ g.Your MySQL connection id is 1Server version: 5.6.36 MySQL Community Server (GPL) Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.mysql > show variables like'% character%' +-- +-- + | Variable_name | Value | + -+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | / usr/share/mysql/charsets/ | +-- -+-- + 8 rows in set (0.00 sec)
11. Create a database
Mysql > create database rise;Query OK, 1 row affected (0.00 sec) mysql > use rise;Database changed
twelve。 Create users and authorize
Mysql > grant all privileges on rise.* to val@'%' identified by '123456 question OK, 0 rows affected (0.00 sec) mysql > flush privileges;Query OK, 0 rows affected (0.00 sec)
% indicates any IP (IP can be specified), val is the user name, and 123456 is the password
The above is all the contents of the article "how to install mysql5.6 in docker under ubuntu". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.