docker images 查看镜像名称
docker run --name 设置容器名 -d 镜像名:TAG标签 -d后台运行
例 docker run --name mysql -d mysql:5.7
或 docker run --name mysql -d mysql(未指定标签,有可能会自动拉取新的镜像)
查看容器运行状态
docker ps -a
STATUS 为 Up 则 容器运行成功; 为Exited 则容器运行失败
查找包
find /-name mysql
查看进程
ps -ef|grep 3306
关闭服务:service mysql stop、kill -91824
kill -91824
解压 tar文件 到指定目录
tar -xvf /var/ftp/test/nginx1.tar -C/data
将一个文件夹下的所有内容复制到另一个文件夹下
cp -r /data/nginx/html/nginx/html/* /data/nginx/html/
删除目录下的所有文件
rm -rf /data/nginx/html/*
远程连接docker的mysql
进入docker中的mysql
docker exec -it mysql bash
输入密码
mysql -uroot -p
显示数据库
show databases;+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema || sys |+--------------------+4 rows inset(0.00 sec)
进入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
查询用户
select user,host from user;+---------------+-----------+| user | host |+---------------+-----------+| root |%|| mysql.session | localhost || mysql.sys | localhost || root | localhost |+---------------+-----------+4 rows inset(0.00 sec)
查询权限 带有%则表示允许所有访问
select host,user,plugin,authentication_string from mysql.user;+-----------+---------------+-----------------------+-------------------------------------------+| host | user | plugin | authentication_string |+-----------+---------------+-----------------------+-------------------------------------------+| localhost | root | mysql_native_password |*-----|| localhost | mysql.session | mysql_native_password |*------|| localhost | mysql.sys | mysql_native_password |*------||%| root | mysql_native_password |*-----|+-----------+---------------+-----------------------+-------------------------------------------+4 rows inset(0.00 sec)
数据库远程连接不上 修改一次root账户的密码
ALTER user 'root'@'%'IDENTIFIEDWITH mysql_native_password BY'123456';
Query OK,0 rows affected(0.00 sec)ALTER user 'root'@'%'IDENTIFIEDWITH mysql_native_password BY'root';
数据库远程连接不上,linux关闭防火墙
1:查看防火状态
systemctl status firewalld
service iptables status
2:暂时关闭防火墙
systemctl stop firewalld
service iptables stop
3:永久关闭防火墙
systemctl disable firewalld
chkconfig iptables off
4:重启防火墙
systemctl enable firewalld
service iptables restart
5:永久关闭后重启
//暂时还没有试过
chkconfig iptables on