Linux System Learning Eighth day-<< engineer Technology >>

Source: Internet
Author: User
Tags stdin email account imap port

Two virtual machines, both fire and hostname modified

Virtual Machine Server0:
# Firewall-cmd--set-default-zone=trusted
# echo server0.example.com >/etc/hostname
# Cat/etc/hostname

Virtual Machine desktop0:
# Firewall-cmd--set-default-zone=trusted
# echo desktop0.example.com >/etc/hostname
# Cat/etc/hostname

? Basic features of the e-mail server
– Provide users with an e-mail storage space (username @ mail domain name)
– Process user-sent messages-delivered to the receiving server
– Process messages received by users--post to mailbox

Protocol for users to send mail: SMTP port 25
User-received mail protocol: POP3 Port 143 IMAP Port

######################################################
Virtual Machine Server0
Building a Basic mail server
1. Installing the Postfix service-side program
[Email protected] ~]# rpm-q postfix
Postfix-2.10.1-6.el7.x86_64

2. Configure the Postfix service, modify the configuration file
[Email protected] ~]# VIM/ETC/POSTFIX/MAIN.CF
76 Rows Myhostname = server0.example.com #指定主机名
83 Rows mydomain = example.com #指定域名
99 Rows Myorigin = Server0.example.com #默认补全的邮件后缀
116 rows inet_interfaces = All #允许所有客户端
164 Rows mydestination = server0.example.com
#判断邮件后缀为本域邮件
Added: Vim Command mode u undo

3. Restart Postfix service, set to boot from
# systemctl Restart Postfix
# Systemctl Enable Postfix

4. Test Mail Sending and receiving

[Email protected] ~]# Useradd YG
[Email protected] ~]# echo 123 | passwd--stdin YG

[Email protected] ~]# Useradd XLN
[Email protected] ~]# echo 123 | passwd--stdin XLN

? Mail sending operation
–mail-s ' message header '-R sender Recipient

? Mail receive operation
–mail [-u user Name]

[Email protected] ~]# mail-s ' test01 '-R YG Xln

There is only one "." In a row , the end of the representative

[Email protected] ~]# mail-u XLN
Enter message number 1 view message content
Quit quitting
#################################################

Nullclient Mail Service

Empty client
? Nullclient, empty Client
– No email account is available, so no mail is required
– but you can send a message to the user on behalf of


I. Configuring DESKTOP0 as a mail server
1. Configure the Postfix service, modify the configuration file
[Email protected] ~]# VIM/ETC/POSTFIX/MAIN.CF

99 Rows Myorigin = Desktop0.example.com
116 Rows inet_interfaces = All
164 Rows mydestination = desktop0.example.com

[Email protected] ~]# systemctl restart Postfix
[Email protected] ~]# Systemctl enable Postfix

Second, configure SERVER0 to be empty client mail server
[Email protected] ~]# VIM/ETC/POSTFIX/MAIN.CF

99 Rows Myorigin = Desktop0.example.com
116 row inet_interfaces = localhost
164 row Mydestination =
317 Rows Relayhost = [172.25.0.10] #指定交给邮件服务器IP地址

[Email protected] ~]# systemctl restart Postfix

Third, testing
On the virtual machine Server0
# echo ABC | Mail-s Test1-r YG Student

On the virtual machine desktop0
# Mail-u Student
######################################################
Database service Basics

? A common relational database management system
– Microsoft's SQL Server
–IBM's DB2
– Oracle, MySQL for Oracle
– Community Open Source version MariaDB


? MariaDB related packages in RHEL7
–mariadb-server: Provision of server-side related system programs
Port number: 3306


I. Deployment of the MARIADB database
1. Installing the Mariadb-server database software
[Email protected] ~]# yum-y install Mariadb-server

2. Start the MARIADB service
[Email protected] ~]# systemctl restart MARIADB
[Email protected] ~]# Systemctl enable MARIADB


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

[[email protected] ~]# MySQL

MariaDB [(None)]> show databases; #查看数据库
MariaDB [(None)]> CREATE Database nsd1709; #创建数据库
MariaDB [(None)]> show databases;

MariaDB [(None)]> drop database nsd1709; #删除数据库
MariaDB [(None)]> show databases;

MariaDB [(None)]> CREATE Database nsd;
MariaDB [(None)]> show databases;

MariaDB [(None)]> quit #退出数据库

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

The database administrator is root, but it does not matter to the system user root

? Change password for database account
–mysqladmin [-u user name] [-p[old password]] password ' new password '

[Email protected] ~]# mysqladmin-u root password ' 123 '

[[email protected] ~]# MySQL
ERROR 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:no)

[Email protected] ~]# mysql-u root-p
Enter Password:

[Email protected] ~]# mysql-u root-p123 #免交互登陆


? No monitoring, only for native
[Email protected] ~]# vim/etc/my.cnf #数据库主配置文件
[Mysqld]
Skip-networking #跳过网络监听
......
[Email protected] ~]# systemctl restart MARIADB

? MariaDB [(none)]> Interactive Instruction
– List database: show databases;
– Using/Selecting the database: Use database name;
– List What tables are in the library: show tables;
– Creating database: Create database name;
– Delete database: drop database name;

Http://172.25.254.254/pub/materials/users.sql

? Import/Restore to Database
–mysql [-u user name] [-p[password]] Database name < backup file. sql

# wget Http://172.25.254.254/pub/materials/users.sql
# mysql-u root-p123 NSD < Users.sql

# mysql-u Root-p123

MariaDB [nsd]> use NSD; #进入nsd库
MariaDB [nsd]> Show tables; #查看都有那些表格


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

Query operations
# mysql-u Root-p123
MariaDB [nsd]> use NSD;

MariaDB [nsd]> SELECT * from base;
MariaDB [nsd]> SELECT * from location;

MariaDB [nsd]> Select Id,name from base;

MariaDB [nsd]> SELECT * from base where name= ' Tom ';

MariaDB [nsd]> SELECT * from location where city= ' Beijing ';

#######################################################
Database authorization

MariaDB [(none)]> Interactive Instruction
–grant permissions list on database name. Table name to User name @localhost
Identified by ' password ';

When the Lisi user logs in from local localhost, enter password 123, the library will get the query permissions for all tables NSD

# mysql-u Root-p123

MariaDB [(None)]> Grant Select on nsd.* to [e-mail protected] identified by ' 123 ';

View the user table information in the MARIADB database

MariaDB [mysql]> Select User,password from Mysql.user;

#####################################################
Case 5: Working with database queries

2. Use the database NSD on the system Server0 and use the phase
The SQL query that is expected to answer the following questions:

1) password is the name of the person who solicitous?

> select * from nsd.base where password= ' solicitous ';
> select * from nsd.base where password= ' solicitous ' and id= ' 3 ';

> select * from nsd.base where name= ' Barbara ' or id= ' 3 ';

2) How many people's names are Barbara while residing in Sunnyvale?

> Use NSD;

> select * from Base,location
where Base.name= ' Barbara ' and location.city= ' Sunnyvale ' and base.id=location.id;

> select COUNT (*) from base,location
where Base.name= ' Barbara ' and location.city= ' Sunnyvale ' and base.id=location.id;

> Insert Base VALUES (6, ' Barbara ', 123456); #插入表记录
> Insert Location VALUES (6, ' Sunnyvale '); #插入表记录
> select * from base;
> select * from location;

1. Disable null password root user access to MARIADB database

> Use MySQL;

> select User,host,password from user where password= ' and user= ' root ';

> Delete from user where password= ' and user= ' root ';

> select User,host,password from User;

> DESC User; #查看表结构


Linux System Learning Eighth day-<< engineer Technology >>

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.