Day08 e-Mail Fundamentals & Database Fundamentals (ENGINNER02)

Source: Internet
Author: User
Tags stdin email account

I. Basic features of e-mail basic 1.1 e-mail server

Provide users with e-mail storage space
Process user-Sent messages-delivered to the recipient server
Process messages received by users-post to mailbox

1.2 Protocols for sending and receiving mail

Smtp:25/tcp
Pop3:110/tcp
Imap:143/tcp

1.3 Building a basic mail server 1.3.1 Installing the Postfix package

Yum-y install Postfix
rpm-qa| grep postfix

1.3.2/etc/postfix/main.cf

Postfix's main profile, which is characterized by top-to-bottom, after setting the option to overwrite the previously set options, i.e. after the application takes effect
Vim/etc/postfix/main.cf
To 76 lines, delete #, modify Myhostname = server0.example.com #指定主机名
To 83 lines, delete #, modify mydomain = example.com #指定域名
To 99 lines, delete #, modify Myorigin = server0.example.com #向外发邮件时标记的来源域
To 116 lines, delete #, modify inet_interfaces = loopback-only# only allow native
To 164 lines, the # is deleted, modified mydestination = server0.example.com #根据邮件后缀来判断是否为本域邮件, the name of server0.example.com is the domain
Myhostname = server0.example.com
MyDomain = example.com
Myorigin = server0.example.com
Inet_interfaces = loopback-only
Mydestination = server0.example.com

1.3.3 Systemctl restart Postfix systemctl enable Postfix

Reboot and set boot postfix

1.4 Send and receive 1.4.1 for test messages Create two users YG, XLN

Useradd YG
echo 123|passwd--stdin YG
Useradd XLN
echo 123|passwd--stdin XLN
ID YG
ID XLN

1.4.2 Send mail command

Mail-s ' Subjec '-R [from] [to]br/> Example 1:[email protected] email [email protected], subject to test01

Hi XLN
Long time No See
How is You
. #当一行只有一个. When the system determines the end of the letter, end the mail and send out br/> Example 2:[email protected] email [email protected], subject to test01
< p="">1.4.3 Receiving mail commands

Mail-u [Username]
Example: XLN viewing a message from YG
Mail-u XLN #回车进入交互式界面
Heirloom Mail Version 12.5 7/5/10. Type? For help.
"/VAR/MAIL/XLN": 1 message 1 new

N 1[email protected]Thu Nov 2 11:26 20/604 "test01"
& 1 #N表示新邮件, 1 for message number 1
Message 1: #输入1选择第一封邮件
From[email protected]Thu Nov 2 11:26:52 2017
Return-path: <[email protected]>
X-original-to:xln
Delivered-to:[email protected]
Date:thu, Geneva 2017 11:26:52 +0800
From:[email protected]
To:[email protected]
subject:test01
User-agent:heirloom MAILX 12.5 7/5/10
Content-type:text/plain; Charset=us-ascii
Status:r

Hi XLN
Long time No See
How is You

& Delete 1-10 #删除1 the e-mail

1.5 nullclient mail server 1.5.1 definition

Empty client Mail server. There is no email account in itself and no mail is required. However, you can send mail to the user instead

1.5.2 Application Scenarios

In the intranet internal system, when the Web, FTP and other servers connected to the external network is slow, or can not access the extranet. When the server is abnormal, in order to be able to send alarm messages quickly, you can contact the e-mail client directly, the fastest speed of the mail to the operation and maintenance personnel, so that operations personnel timely processing.
However, due to the prevalence of monitoring servers, it is now rare to use the empty client mode

1.5.3 configuring Desktop0 as a back-end mail server

To operate on Desktop0:
Two methods:
Method 1: The Script Lab smtp-nullclient Setup is automatically set up to substantially modify and add these rows
Modification section:
Inet_interfaces = All
Add part:
Mynetworks = 172.25.0.0/24
Smtpd_sasl_auth_enable = yes
Smtpd_sasl_type = Dovecot
Smtpd_sasl_path = Private/auth
Smtpd_recipient_restrictions = Permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
Smtpd_tls_security_level = May
Smtpd_tls_cert_file =/etc/pki/tls/certs/postfix.pem
Smtpd_tls_key_file =/etc/pki/tls/private/postfix.pem

Method 2: Manually modify the configuration file
Vim/etc/postfix/main.cf
To 99 lines, delete #, modify Myorigin = desktop0.example.com #默认补全的邮件后缀
To 116 lines, delete #, modify inet_interfaces = All #允许所有客户端
To 164 lines, the # is deleted, modified mydestination = desktop0.example.com #投递域的域名, the name of desktop0.example.com is the domain
Mynetworks = 172.25.0.0/24
Myorigin = desktop0.example.com
Mydestination = desktop0.example.com
Inet_interfaces = All

1.5.4 Configuring the Nullclient server

To operate on Server0:
Vim/etc/postfix/main.cf
To 99 lines, delete #, modify Myorigin = desktop0.example.com #向外发邮件时标记的来源域
To 116 lines, delete #, modify inet_interfaces = Loopback-only #仅允许本机
To 164 lines, delete #, modify mydestination = #设置为空表示没有投递域
To 264 lines, delete #, modify Mynetworks = 127.0.0.0/8 [:: 1]/128
To 317 lines, delete #, modify Relayhost = 172.25.0.10 #指定后端 (target) mail server
Restart Service Systemctl restart Postfix systemctl enable Postfix
Inet_interfaces = loopback-only
Mydestination =
Mynetworks = 127.0.0.0/8 [:: 1]/128
Relayhost = [smtp0.example.com]

1.5.5 Testing the Nullclient server

Write an e-mail to student on Server0, at this time in Server0 can not receive mail, mail will go to desktop0 up

II. Database Service Basics 2.1 table fields & Tables Records

Number name Phone number address
1 ZS 1111111111 Shanghai
2 LS 2222222222 Beijing
3 ww 3333333333 Guangzhou
Black Area: Table field
Other areas: Table records

2.2 Yum-y Install Mariadb-server MARIADB

Install Mariadb-server (server side) and MARIADB (client and tools)

2.3 Mariadb Introduction

Open source database system developed by MySQL developers
Port number 3306/tcp
TAB key not supported
All commands must with; end

2.4 Common commands

show databases; #显示所有数据库
Create database nsd1709; #创建数据库nsd1709
Drop databases nsd1709; #删除数据库nsd1709
status; #查看状态
Quit; #退出
\c command input error after end command line
‘; End command line after command input error
"; End command line after command input error
\g the results of a query to be displayed vertically

2.5 Modifying the database Password 2.5.1 initialization setting password

Attention! The database administrator is root, but has no relationship with the root user of the system
Execute on Linux Systems
mysqladmin-u root password ' 123 ' #设置数据库管理员root的密码为123
After you change the password, you must log in to the database via mysql-uroot-p123, but this command displays the password, which is extremely insecure. Must be logged in interactively
Mysql-uroot-p
Enter Password:

2.5.2 Hack Password

Execute on Linux Systems
Systemctl Stop MARIADB
Mysqld_safe--skip-grant-tables & #跳过检查授权表启动
[1] 25828
[email protected] mysql]# 170925 14:46:03 mysqld_safe Logging to '/var/log/mariadb/mariadb.log '.
170925 14:46:03 mysqld_safe A mysqld process already exists
Mysql-h127.0.0.1-uroot-p
SET password for ' root ' @ ' localhost ' =password (' newpassword ');
Exit
Kill-9 25828
Systemctl Start mariadb

2.5.3 Modify Password Method 1

Execute in database
Use MySQL;
UPDATE user SET Password=password (' newpassword ') WHERE user= ' root ';
Flush privileges;
Exit

2.5.4 Modify Password Method 2

Execute in database
SET password for ' root ' @ ' localhost ' =password (' newpassword ');
Systemctl Start mariadb

2.6 Master configuration File modification

Vim/etc/my.cnf
In the next line below Mysqld, enter the following statement
Skip-networking #跳过网络监听, only the local service

2.7 Database additions and deletions

Use "," between tables and tables
Use "." Between libraries and tables

2.7.1 show databases;

Show all databases

2.7.2 use NSD;

Select and open the NSD database

2.7.3 Show tables;

View the tables inside the database

2.7.4 Importing databases

Command format: mysql-u[username]-P [database_name] < [backup_files]
Executing on Linux systems
wget Http://172.25.0.254/pub/materials/users.sql
Mysql-uroot-p NSD < Users.sql
Mysql-uroot-p
MariaDB [nsd]> use NSD;
MariaDB [nsd]> Show tables;
+---------------+
| TABLES_IN_NSD |
+---------------+
| Base |
| Location |
+---------------+

2.7.5 select * from Nsd.base;

Command format: Select table field from database name. Table name;

Querying all table field information for the base table of the NSD database
MariaDB [nsd]> SELECT * from Nsd.base;
+------+---------+------------+
| ID | name | password |
+------+---------+------------+
| 1 | Tom | 123 |
| 2 | Barbara | 456 |
| 3 | James | solicitous |
| 4 | Smith | Tarena |
| 5 | Barbara | pwd123 |
+------+---------+------------+
5 rows in Set (0.00 sec)

2.7.6 SELECT * from base where name= ' Tom ';

Query for a user with name Tom
MariaDB [nsd]> SELECT * from base where name= ' Tom ';
+------+------+----------+
| ID | name | password |
+------+------+----------+
| 1 | Tom | 123 |
+------+------+----------+
1 row in Set (0.00 sec)

2.7.7 SELECT * from nsd.base where password= ' solicitous ' and id= ' 3 ';

Query password is solicitous and id=3 table records

2.7.8 SELECT * from nsd.base where name= ' Barbara ' or id= ' 3 ';

Query for table records with name Barbara or id=3

2.7.9 Select COUNT (*) from base,location where base.name= ' Barbara ' and location.city= ' Sunnyvale ' and base.id=location.id ;

Find the number of people living in Sunnyvale named Barbara

2.8 Authorization of the database

Command format: Grant permission list on database name. Table name to user name @localhost identified by ' password '

2.8.1 Permissions List

Insert: Add
Delete: Remove
Update: Modify
Select: Query

Grant SELECT on nsd.* to [email protected] identified by ' 456 ' #lisi用户在本地登录后拥有对nsd库的所有表的查询权限
Select User,password from Mysql.user where user= ' Lisi ';

2.9 Modification of the database 2.9.1 Insert base values (6, ' Barbara ', 123456);

Add a table record, Id=6,name=barbara, password =123456

2.9.2 Insert Location VALUES (6, ' Sunnyvale ');

Add a table record, Id=6,city=barbara

2.10 Deletion of database records

Delete from user where password= ' and user= ' root ';
Delete a record with a user name of root and a blank password

2.11 View Table Structure

Desc nsd.base;

Day08 e-Mail Fundamentals & Database Fundamentals (ENGINNER02)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.