1. 安装http服务并在服务目录创建readme文件,里面写上hello world. 通过浏览器可以访问到自己开放的这个http服务,即打开 http://127.0.0.1/readme 看到这个服务,80是默认端口,可以不用写成 http://127.0.0.1:80/readme
    1. yum install httpd

    Apache 的所有配置文件都在 /etc/httpd/conf 和 /etc/httpd/conf.d 中,网站内容默认在 /var/www/www 下。可以通过 /etc/httpd/conf/httpd.conf 修改端口信息

    1. [root@localhost /]# echo "hello world" >> /var/www/html/readme
    2. [root@localhost /]# curl http://127.0.0.1/readme
    3. hello world
    1. http服务配置端口从80端口修改到8080端口,并且实现关机重启后服务自动启动
    1. [root@localhost /]# vim /etc/httpd/conf/httpd.conf
    2. # Listen 80
    3. Listen 8080
    4. [root@localhost /]# httpd -k restart
    5. [root@localhost /]# curl localhost:8080/readme
    6. hello world

    配置开机自启动

    1. [root@localhost ~]# systemctl enable httpd.service
    2. Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
    1. 安装mysql数据库服务,并进行常见的运维(导出,备份,还原)操作
    1. # 下载并安装mysql官方的rpm
    2. [root@localhost ~]# wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
    3. [root@localhost ~]# yum -y install mysql57-community-release-el7-10.noarch.rpm
    4. [root@localhost ~]# yum -y install mysql-community-server
    5. [root@localhost ~]# systemctl start mysqld.service # 启动mysql
    6. # 查看初始密码
    7. [root@localhost ~]# grep "password" /var/log/mysqld.log
    8. 2020-04-08T11:20:58.803499Z 1 [Note] A temporary password is generated for root@localhost: ejV_&WVyV5+u
    9. 2020-04-08T11:21:51.284955Z 2 [Note] Access denied for user 'root'@'localhost' (using password: NO)
    10. 2020-04-08T11:21:56.049757Z 3 [Note] Access denied for user 'root'@'localhost' (using password: NO)

    进入数据库

    1. [root@localhost ~]# mysql -uroot -p

    输入初始密码,mysql默认必须修改密码之后才能进行操作

    1. mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';
    1. 并实现创建一个数据库(例如叫testdb),并在数据库内创建一个表(score_table),表内包含id(整形),name(字符串),score(整形)这么几个字段,并且自己insert一些记录。
    1. mysql> create database testdb default character set UTF8;
    2. mysql> create table score_table (
    3. -> id integer(16),
    4. -> name varchar(32),
    5. -> score integer(10)
    6. -> );
    7. Query OK, 0 rows affected (0.01 sec)
    8. mysql> insert into score_table (id, name, score) values (1, 'chao', 100), (2, 'test', 98), (3, 'haha', 86);
    9. Query OK, 3 rows affected (0.00 sec)
    10. Records: 3 Duplicates: 0 Warnings: 0
    1. 能够把创建的表dump出来,保存为score_table.sql文件。
    1. [root@localhost ~]# mysqldump -uroot -p --databases testdb --tables score_table > score_table.sql
    1. 把数据库里的score_table表删除了,用这个score_table.sql能恢复出原表出来。

    进入mysql 删除 score_table

    1. mysql> drop table score_table;

    恢复数据库

    1. [root@localhost ~]# mysql -uroot -p testdb < score_table.sql
    1. 学习如果将score_table表中,score(分数)在90分以上的同学记录导出来。
    1. [root@localhost ~]# mysqldump -uroot -p --databases testdb --tables score_table --where='score > 90' > score_table.sql