Docker builds the Mariadb Database

Source: Internet
Author: User
Tags docker ps docker run

Docker builds the Mariadb Database

1. Obtain the mariadb image address.

Root @ debian1 :~ /Nginx # docker search mariadb
Name description stars official automatic
Mariadb MariaDB is a community-developed fork of M... 1417 [OK]
Bitnami/mariadb Bitnami MariaDB Docker Image 39 [OK]

2. Pull the latest maridb Image
Root @ debian1 :~ /Nginx # docker pull mariadb
Using default tag: latest
Latest: Pulling from library/mariadb
3: Start, mariadb Image

Root @ debian1 :~ /Nginx # docker run -- privileged-d-e TIMEZONE = Asis/Shanghai-e MYSQL_ROOT_PASSWORD = hanye131-e SERVER_ID = 1-v $ PWD/mysql_db: /var/lib/mysql-p 3306: 3306 mariadb
Bytes
Root @ debian1 :~ /Nginx # docker ps-
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
255650e5e83d mariadb "docker-entrypoint..." 3 seconds ago Up 1 second 0.0.0.0: 3306-> 3306/tcp festive_ride

4. view the port occupied by startup
Root @ debian1 :~ /Nginx # netstat-tunl | grep 3306
Tcp6 0 0: 3306: * LISTEN

5. Link to mysql of docker
Root @ debian1 :~ /Nginx # mysql-uroot-phanye131-h127.0.0.1
Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 8
Server version: 5.5.5-10.2.6-MariaDB-10.2.6 + maria ~ Jessie mariadb.org binary distribution

Copyright (c) 2000,201 7, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
Affiliates. Other names may be trademarks of their respective
Owners.

Type 'help; 'or' \ H' for help. type' \ C' to clear the current input statement.

Mysql>
6. Error Solution
If you are prompted that the sock file cannot be linked, You need to link to the mariadb container of docker to authorize the link.
6.1, link to docker mariadb
Obtain the container id of mariadb.

Root @ debian1 :~ /Nginx # docker ps-
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
255650e5e83d mariadb "docker-entrypoint..." 10 minutes ago Up 10 minutes 0.0.0.0: 3306-> 3306/tcp festive_ride
360baf71efb0 a3ae0b27ec04 "/run. sh bash" 3 hours ago Exited (2) 3 hours ago nginx

The container id of the mariadb image here is 255650e5e83d.

6.2. log on to mariadb.

Root @ debian1 :~ /Nginx # docker exec-it 255650e5e83d bash
Root @ 255650e5e83d :/#
6.3. Authorize the link permission of the root user of mysql (which is also set by the user)
MariaDB [(none)]> grant all on *. * to 'root' @ '2017. 192.% 'identified by 'hanye131 ';
Query OK, 0 rows affected (0.01 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.01 sec)
7. Connect to mysql again.




























Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.