Install mysql 8.0

docker run -p 63306:3306 -e MYSQL_ROOT_PASSWORD=zhaooleemysql --name zhaooleemysqldb -dMysql: 8.0Copy the code
  • p 53306:3306Map port 3306 of the Docker container to port 63306 of the host
  • -e MYSQL_ROOT_PASSWORD=zhaooleemysqlThe password of user root is zhaooleemysQL
  • --name zhaooleemysqldbThe name of the new container is ZHAOoleemysQLDB
  • Mysql: 8.0The mysql database version is 8.0

Into the container

docker exec -it zhaooleemysqldb bash
Copy the code

Logging In to the Database

mysql -uroot -p
zhaooleemysql
Copy the code

Create a new user (8.0 is more strict, remote login with root user is troublesome, we choose to create a new user)

create user 'zhaoolee' identified with mysql_native_password by 'eelooahzpw';
Copy the code

Zhaoolee new user name zhaoolee mysql_native_password The password encryption mode is mysql_native_password eelooahzpw The new user password is eelooahzpw

Add permissions for the new user zhaoolee

grant all privileges on *.* to 'zhaoolee';
Copy the code

Refresh the permissions

flush privileges;
Copy the code

Creating a Database

create database v2fy charset=utf8;
Copy the code
  • The name of the new database isv2fy

Exiting the database

exit
Copy the code

Exit the Docker container

control +  p  + q
Copy the code

Try to connect using Navicat