使用docker创建mysql实例

 

➜  docker docker run --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=xxx -d mysql
190c645f7bed945d6319feccfd8f861ce8ee9211785dc7c504da621418e7ee32
➜  docker docker exec -it 190
"docker exec" requires at least 2 arguments.
See 'docker exec --help'.

Usage:  docker exec [OPTIONS] CONTAINER COMMAND [ARG...]

Run a command in a running container
➜  docker docker exec -it 190 bash  
root@190c645f7bed:/# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.16 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> create user 'kevin'@'%' identified with mysql_native_password by 'xxx';
Query OK, 0 rows affected (0.01 sec)

mysql> grant all privileges on *.* to 'kevin'@'%';
Query OK, 0 rows affected (0.01 sec)

mysql> 

 

你可能感兴趣的:(docker)