ubuntu-docker-mysql8

新建目录

briup@briup-Macmini:~/mydocker/mysql8$ ls
conf  data  mysql-file
briup@briup-Macmini:~/mydocker/mysql8$ ls data/
 85261065eb73.pid   binlog.index      client-key.pem   ib_logfile1     mysql.ibd            server-cert.pem   undo_002
 auto.cnf           ca-key.pem        ib_buffer_pool   ibtmp1          performance_schema   server-key.pem
 binlog.000001      ca.pem            ibdata1         '#innodb_temp'   private_key.pem      sys
 binlog.000002      client-cert.pem   ib_logfile0      mysql           public_key.pem       undo_001
briup@briup-Macmini:~/mydocker/mysql8$ ls conf/
briup@briup-Macmini:~/mydocker/mysql8$ ls mysql-file/

安装命令

briup@briup-Macmini:~/mydocker/mysql8$ docker run -itd -p 3308:3306 --name mysql8 -v /home/briup/mydocker/mysql8/conf:/etc/mysql -v /home/briup/mydocker/mysql8/data:/var/lib/mysql -v /home/briup/mydocker/mysql8/mysql-file:/var/lib/mysql-files  -e MYSQL_ROOT_PASSWORD=123456 mysql

数据库配置

briup@briup-Macmini:~/mydocker/mysql8$ docker exec -ti mysql8 bash
root@85261065eb73:/# ls
bin   dev			  entrypoint.sh  home  lib64  mnt  proc  run   srv  tmp  var
boot  docker-entrypoint-initdb.d  etc		 lib   media  opt  root  sbin  sys  usr
root@85261065eb73:/# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.17 MySQL Community Server - GPL

Copyright (c) 2000, 2019, 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> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'your password';
Query OK, 0 rows affected (0.12 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.07 sec)

mysql> exit
Bye
root@85261065eb73:/# exit
exit
briup@briup-Macmini:~/mydocker/mysql8$ 

你可能感兴趣的:(docker,mysql8,linux,docker,mysql8)