亚洲精品中文字幕无码专区一,中文字幕av一区乱码深夜动态福利,粗大的内捧猛烈进出少妇

          系統城裝機大師 - 固鎮縣祥瑞電腦科技銷售部宣傳站!

          當前位置:首頁 > server > anz > 詳細頁面

          aarch64服務器部署mysql的流程分析

          時間:2022-10-02來源:www.snowmanhill.com作者:電腦系統城

          aarch64服務器-部署mysql

          aarch64服務器-部署nacos

          1、創建工作目錄

          1 mkdir -p /apps/mysql/{mydir,datadir,conf,source}

          2、編寫docker-compose.yaml

          1
          2
          3
          4
          5
          6
          7
          8
          9
          10
          11
          12
          13
          14
          15
          16
          17
          18
          19
          20
          version: '3'
          services:
            mysql:
              restart: always
              image: mysql/mysql-server
              container_name: mysql-lable
              volumes:
                - /apps/mysql/mydir:/mydir
                - /apps/mysql/datadir:/var/lib/mysql
                - /apps/mysql/conf/my.cnf:/etc/my.cnf
                # 數據庫還原目錄 可將需要還原的sql文件放在這里
                - /apps/mysql/source:/docker-entrypoint-initdb.d
              environment:
                - "MYSQL_ROOT_PASSWORD=xxx"
                - "MYSQL_DATABASE=xxx"
                - "TZ=Asia/Shanghai"
              ports:
                # 使用宿主機的3306端口映射到容器的3306端口
                # 宿主機:容器
                - 3307:3306

          所在服務器

          1
          2
          3
          4
          5
          192.168.2.241  
          root@minio-3:~/mysql-8.0# ls
          docker-compose.yaml
          root@minio-3:~/mysql-8.0# pwd
          /root/mysql-8.0

          3、編寫數據庫配置文件。

          /apps/mysql/conf/my.cnf

          1
          2
          3
          4
          5
          6
          7
          8
          9
          10
          11
          [mysqld]
          user=mysql
          default-storage-engine=INNODB
          character-set-server=utf8
          character-set-client-handshake=FALSE
          collation-server=utf8_unicode_ci
          init_connect='SET NAMES utf8'
          [client]
          default-character-set=utf8
          [mysql]
          default-character-set=utf8

          4、啟動

          啟動容器的時候,需要先檢查所使用的端口是否被占用。

          1
          2
          3
          4
          5
          $ docker-compose up -d
          $ docker-compose ps
          Name                 Command             State           Ports
          --------------------------------------------------------------------------
          mysql-lable   docker-entrypoint.sh mysqld   Up      0.0.0.0:3306->3306/tcp

          image-20220915112712741

          5、測試

          進入容器,使用密碼登錄數據庫,并查看數據庫有沒有創建所指定的庫,庫里面有沒有導入你的sql數據

          1
          2
          3
          4
          5
          6
          7
          8
          9
          10
          11
          12
          13
          14
          15
          16
          17
          18
          19
          20
          21
          22
          23
          24
          25
          26
          27
          28
          29
          30
          31
          32
          33
          34
          ### docker exec -it 容器ID(使用docker ps查看) /bin/bash
          $ docker exec -it e592ac9bfa70 /bin/bash
          # root@e592ac9bfa70:/# mysql -uroot -p
          Enter password:
          Welcome to the MySQL monitor.  Commands end with ; or \g.
          Your MySQL connection id is 31451
          Server version: 5.7.18 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 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>
           
          # 查看數據
          mysql> show databases;
          +--------------------+
          | Database           |
          +--------------------+
          | information_schema |
          | mysql_data_test    |
          | mysql              |
          | performance_schema |
          | sys                |
          +--------------------+
          5 rows in set (0.00 sec)
           
          mysql> use mysql_data_test  #這個是我自己的恢復數據文件
          mysql> show tables;
          .......

           

          記錄報錯

          連接報錯

          1 Host is not allowed to connect to this MySQL server解決方法
          1 https://blog.csdn.net/bingjianit/article/details/54384299 #解決文章
          1
          2
          3
          4
          在裝有MySQL的機器上登錄MySQL mysql -u root -p密碼
          執行use mysql;
          執行update user set host = '%' where user = 'root';這一句執行完可能會報錯,不用管它。
          執行FLUSH PRIVILEGES;

          創建用戶授權用戶,修改root密碼

          1 mysqladmin -uroot -p'123456'  password 'xxxx'

          一. 創建用戶

          命令:

          1
          2
          3
          4
          5
          6
          7
          CREATE USER 'username'@'host' IDENTIFIED BY 'password';
          例子:
          CREATE USER 'dog'@'localhost' IDENTIFIED BY '123456';
          CREATE USER 'pig'@'192.168.1.101_' IDENDIFIED BY '123456';
          CREATE USER 'pig'@'%' IDENTIFIED BY '123456';
          CREATE USER 'pig'@'%' IDENTIFIED BY '';
          CREATE USER 'pig'@'%';

          二. 授權:

          命令:

          1
          2
          3
          4
          GRANT privileges ON databasename.tablename TO 'username'@'host'
          例子:
          GRANT SELECT, INSERT ON test.user TO 'pig'@'%';
          GRANT ALL ON *.* TO 'pig'@'%';

          三. 授權:

          命令:

          1 GRANT privileges ON databasename.tablename TO ‘username'@‘host'

          例子:

          1
          2
          GRANT SELECT, INSERT ON test.user TO ‘pig'@‘%';
          GRANT ALL ON . TO ‘pig'@‘%';

          到此這篇關于aarch64服務器部署mysql的文章就介紹到這了

          分享到:

          相關信息

          系統教程欄目

          欄目熱門教程

          人氣教程排行

          站長推薦

          熱門系統下載

          亚洲精品中文字幕无码专区一,中文字幕av一区乱码深夜动态福利,粗大的内捧猛烈进出少妇