Dahne-linux Basic-day08-mail server and Database service Foundation

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


################################################################################################
To modify the firewall and host name:
Virtual Machine Server0:
Firewall-cmd--set-default-zone=trusted
Vim/etc/hostname
Server0.example.com
Virtual Machine desktop0:
Fireawall-cmd--set-default-zone=trusted
Vim/etc/hostname
Desktop0.example

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

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:
Build a basic mail server
One. Install the Postfix server program:
#yum-y install postfix//installing Postfix server program
#rpm-Q postfix//To see if the installation was successful

Two. Configure the Postfix service, modify the configuration file

#vim the path to the/ETC/POSTFIX/MAIN.CF//configuration file
Myhostname = server0.example.com//Configure host Name
MyDomain = example.com//Specify Domain name
Myorigin = server0.example.com//Sender Address field default auto-complete suffix
Inet_interfaces = ALL//Allow all clients
Mydestination = server0.example.com//Determine if the message suffix is a domain message

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

Four. Testing

Sending and receiving mail:
Virtual Machine Server0:
#useradd YG
#echo 123 | passwd--stdin YG//Set YG user password
#useradd XLN
#echo 123 | passwd--stdin XLN//Set XLN user password

To send a message:
–mail-s ' message header '-R sender Recipient
#su-yg
#mail-S ' test '-R YG XLN//message subject to test sender YG recipient xln-s means subject-r represents source
123
456
.
Write the message content when there is only one line. When the writing is complete

Receive mail:
–mail [-u user Name]
#su-XLN
#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 line Mydestination =//Close the Receive port
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; #查看表结构



























Dahne-linux Basic-day08-mail server and Database service Foundation

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.