网络命令
查看本机的ip地址
ip addr -- 查看本机的IP地址
inet 192.168.133.33/
服务
service 服务名 start|stop|restart|status
service network start 启动网络服务
service network stop 关闭网络服务
service network restart 重启网络服务
service network status 显示网络服务状态
-- service network start stop restart status
systemctl start|stop|restart|status 服务名
systemctl status network -- 查看网络服务状态
systemctl stop network
systemctl start network
systemctl restart network
systemctl disable network 开机禁用
systemctl enable network 开机启动
-- 关闭NetworkManager网络服务 避免和network冲突
systemctl status NetworkManager
systemctl stop NetworkManager
systemctl disable NetworkManage
防火墙服务
systemctl status firewalld ****
Active: active (running) since Fri 2021-10-08 23:02:24 CST; 10h ago -- 防火墙在运行
systemctl start firewalld
systemctl stop firewalld
systemctl restart firewalld
systemctl disable firewalld 配置上自动关闭
systemctl enable firewalld
如果报错 重新安装防火墙 yum -y install firewalld.service
我们配置关闭防火墙 systemctl stop firewalld
配置开启禁用 systemctl disable firewalld
主机名
[root@localhost ~]# hostname -- 查看当前主机名
localhost.localdomain
[root@localhost ~]# hostname linux01 -- 临时修改主机名
[root@localhost ~]# hostname
linux01
[root@localhost ~]# vi /etc/hostname -- 修改主机名 永久
[root@localhost ~]# cat /etc/hostname
linux01
--reboot 重启生效
[root@linux01 ~]#
域名
在windows上配置虚拟机的ip映射
C:\Windows\System32\drivers\etc\hosts
192.168.133.33 linux01
在linux上配置windows的域名映射
vi /etc/hosts
192.168.133.2 windows
网络端口查看
netstat
英文:network statistics 命令路径:/bin/netstat 执行权限:所有用户
作用:主要用于检测主机的网络配置和状况
-a all显示所有连接和监听端口
-t (tcp)仅显示tcp相关连接
-u (udp)仅显示udp相关连接
-n 使用数字方式显示地址和端口号
-l (listening) 显示监控中的服务器的socket
-p port
-- 执行命令
[root@linux01 ~]# netstat -nltp | grep 3306
tcp6 0 0 :::3306 :::* LISTEN 1748/mysqld
[root@linux01 ~]# service mysqld stop
Redirecting to /bin/systemctl stop mysqld.service
[root@linux01 ~]# netstat -nltp | grep 3306
[root@linux01 ~]#
注意:如果netstat命令报错 notfound 下载安装
-- 安装网络工具
yum -y install net-tools
Linux安装mysql
1. 进入到/opt/apps文件夹
2. yum -y install wget
3. wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
4. yum -y install mysql57-community-release-el7-10.noarch.rpm
5. yum -y install mysql-community-server --nogpgcheck
6. systemctl start mysqld
7. netstat -nltp | grep 3306
8. grep "password" /var/log/mysqld.log
```
2021-11-21T19:13:01.139721Z 1 [Note] A temporary password is generated for root@localhost: hUk5ak36Pn%T
```
9. mysql -uroot -phUk5ak36Pn%T
-
修改密码
登陆mysql后#这两个设置后 密码可以简单设置 mysql> set global validate_password_policy=0; mysql> set global validate_password_length=1; #修改密码 mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';