Skip to content

Instantly share code, notes, and snippets.

@nanmi
Last active January 13, 2021 08:22
Show Gist options
  • Save nanmi/c22599bd75d87b5d3acd0d0cfafc3b22 to your computer and use it in GitHub Desktop.
Save nanmi/c22599bd75d87b5d3acd0d0cfafc3b22 to your computer and use it in GitHub Desktop.
搭建mysql容器并远程连接
#启动容器
docker run -it --rm --name mysql -e MYSQL_ROOT_PASSWORD=123456 -p 3306:3306 -d mysql
#进入容器
apt-get update
passwd #设置密码
apt-get install ssh openssh-server vim
#修改/etc/ssh/sshd_config 修改为PermitRootLogin yes和修改为UsePAM no
$ mysql -uroot -p123456 或 (mysql -uroot -p )
mysql> select host,user,plugin,authentication_string from mysql.user;
mysql> ALTER user 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
mysql> FLUSH PRIVILEGES;
mysql> quit;
#重启ssh服务
/etc/init.d/ssh restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment