当前位置:Gxlcms > 数据库问题 > Linux 邮件基础 数据库基础

Linux 邮件基础 数据库基础

时间:2021-07-01 10:21:17 帮助过:25人阅读

172.25.254.254#53


Name: server0.example.com

Address: 172.25.0.11


[root@server0 ~]# firewall-cmd --set-default-zone=trust     #设置默认防火墙区域为trust

[root@server0 ~]# echo server0.example.com > /etc/hostname     #名字改为server0.example.com


#######################################################################################


用户发邮件的协议


发邮件协议   SMTP   端口25

收邮件协议   pop3   端口110  /  IMAP    端口143


修改配置文件

[root@server0 ~]# vim /etc/postfix/main.cf 

myhostname = server0.example.com           #76行   指定主机名

mydomain = example.com                     #83行  指定域名

myorigin = server0.example.com             #99行  默认补全的邮件后缀

inet_interfaces = all                      #116行  允许所有客户端

mydestination = sercer0.example.com        #164行  判断邮件后缀为本域邮件



重启 开机自启

[root@server0 ~]# systemctl restart postfix

[root@server0 ~]# systemctl enable postfix



创建用户  添加密码

[root@server0 ~]# useradd yg

[root@server0 ~]# echo 123 > passwd --stdin yg

[root@server0 ~]# useradd xln

[root@server0 ~]# echo 123 > passwd --stdin xln



收发邮件


[root@server0 ~]# mail -s ‘haha‘ -r yg xln

123456789

987654321

.                       #.表示输入完毕

EOT


[root@server0 ~]# mail -u xln

Heirloom Mail version 12.5 7/5/10.  Type ? for help.

"/var/mail/xln": 1 message 1 new

>N  1 yg@server0.example.c  Thu Nov  2 11:27  19/586   "haha"

& 1

Message  1:

From yg@server0.example.com  Thu Nov  2 11:27:15 2017

Return-Path: <yg@server0.example.com>

X-Original-To: xln

Delivered-To: xln@server0.example.com

Date: Thu, 02 Nov 2017 11:27:15 +0800

From: yg@server0.example.com

To: xln@server0.example.com

Subject: haha

User-Agent: Heirloom mailx 12.5 7/5/10

Content-Type: text/plain; charset=us-ascii

Status: R


123456789

987654321


& quit

Held 1 message in /var/mail/xln


###############################################################################



nullclient  空客户端服务


配置终端

[root@desktop0 ~]# vim /etc/postfix/main.cf


myorigin = desktop0.example.com             #99行  默认补全的邮件后缀

inet_interfaces = all                       #116行  允许接受所有客户端

mydestination = desktop0.example.com        #164行  判断邮件后缀为本域邮件



配置nullclient客户端

[root@server0 ~]# vim /etc/postfix/main.cf


myorigin = desktop0.example.com             #99行   默认补全的邮件后缀

inet_interfaces = localhost                 #116行  只接受本地主机

mydestination =                             #164行  没有本域邮件

relayhost = [172.25.0.10]                   #317行  指定交给邮件服务器IP地址 


发送邮件

[root@server0 ~]# echo hahahahahahaha | mail -s test1 -r yg student


[root@desktop0 ~]# mail -u student

Heirloom Mail version 12.5 7/5/10.  Type ? for help.

"/var/mail/student": 1 message 1 new

>N  1 yg@desktop0.example.  Thu Nov  2 15:09  21/826   "test1"

& 1

Message  1:

From yg@desktop0.example.com  Thu Nov  2 15:09:17 2017

Return-Path: <yg@desktop0.example.com>

X-Original-To: student@desktop0.example.com

Delivered-To: student@desktop0.example.com

Date: Thu, 02 Nov 2017 15:09:18 +0800

From: yg@desktop0.example.com

To: student@desktop0.example.com

Subject: test1

User-Agent: Heirloom mailx 12.5 7/5/10

Content-Type: text/plain; charset=us-ascii

Status: R


hahahahahahaha


##################################################################################


数据库


部署maridb数据库

[root@server0 ~]# yum -y install mariadb-server


进入数据库

[root@server0 ~]# mysql


MariaDB [(none)]> show databases;

MariaDB [(none)]> create database hahaha;

MariaDB [(none)]> drop database hahaha;

MariaDB [(none)]> create database nsd;

MariaDB [(none)]> quit


设置密码


[root@server0 ~]# mysqladmin -u root password ‘123‘ 

[root@server0 ~]# mysql                              #有密码情况下输入mysql会报错

ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO) 


[root@server0 ~]# mysql -u root -p          #有密码情况下交互式登陆

Enter password: 


免交互式登陆

[root@server0 ~]# mysql -u root -p123      #p后直接加上密码  安全性差


跳过网络监听

[root@server0 ~]# vim /etc/my.cnf                #数据库主配置文件        

skip-networking

[root@server0 ~]# systemctl restart mariadb


导入数据到数据库

[root@server0 ~]# wget http://172.25.254.254/pub/materials/users.sql


[root@server0 ~]# mysql -u root -p123 nsd < users.sql

[root@server0 ~]# mysql -u root -p123


MariaDB [(none)]> use nsd;

MariaDB [nsd]> show tables;


单独授权用户

MariaDB [nsd]> grant select on nsd.* to lisi@localhost identified by‘123‘; 

MariaDB [nsd]> select user.password from mysql.user;


找出有几个叫barbara且住在sunnyvale的人的个数

MariaDB [nsd]> select * from base,location where base.name= ‘barbara‘ and location.city=‘sunnyvale‘ and base.id=location.id;

MariaDB [nsd]> select count(*) from base,location where base.name= ‘barbara‘ and location.city=‘sunnyvale‘ and base.id=location.id;


MariaDB [nsd]> insert base values(6 ,‘barbara‘,123456);

MariaDB [nsd]> insert location values(6,‘sunnyvale‘);

MariaDB [nsd]> select count(*) from base,location where base.name= ‘barbara‘ and location.city=‘sunnyvale‘ and base.id=location.id;




Linux 邮件基础 数据库基础

标签:云计算基础 linux基础

人气教程排行