*************************************************************************************
********************************mariadb**********************************************
*************************************************************************************
#1. 安装mysql
yum search mariadb //查找与mariadb有关的软件包
yum install mariadb mariadb-server -y //安装mariadb的server软件和client软件
## 启动mariadb服务
systemctl start mariadb
systemctl enable mariadb
## mariadb监听的端口
netstat -antlpe | grep mysql
ss -antlpe | grep mysql
vim /etc/services //所有服务与端口默认的对应关系
## 只允许本地连接,阻断所有来自网络的连接
vim /etc/my.cnf
skip-networking=1
systemctl restart mariadb
#2. mariadb的初始化
## 设置mysql的登陆密码
mysql_secure_installation
mysql -uroot -p
## mysql基本操作语句
show databases; //显示数据库,类似于目录,里面包含多个表
use mysql; //进入名称为mysql的数据库
show tables; //显示该数据库中的表
desc user; //显示表的结构
select * from user; //显示user表中的内容
select Host,User,Password from user; //显示表中某几列
create database westos; //创建以数据库名称为westos
create table westosuser( //创建一表
-> username varchar(10) not null,
-> passwd varchar(6) not null
-> );
insert into westosuser values ('user1','123'); //向表中插入内容
insert into westosuser(passwd,username) values("456","user2"); //按照指定顺序向表中插入数据
update westosuser set passwd='456' where username="user1"; //更新表中的内容
alter table westosuser add sex varchar(3); //添加sex列到westosuser表中
delete from westosuser where username="user1"; //删除表中用户名为user1的记录
drop table westosuser; //删除表
drop database westos; //删除数据库
## 用户和访问权限的操作
create user hello@localhost identified by 'hello';
//创建用户hello,可在本机登陆,密码为hello
create user hello@'%' identified by 'hello';
//创建用户hello,可在远程登陆,密码为hello
create database mariadb; //创建一数据库mariadb,对普通用户进行
grant all on mariadb.* to hello@localhost;
//给hello@localhost用户授权,如果为all,授权所有权限(insert,update,delete,select,create)
flush privileges; //刷新,重载授权表
show grants for hello@localhost; //查看用户授权
revoke delete,update on mariadb.* from hello@localhost;
//删除指定用户授权
drop user hello@localhost; //删除用户
#4. 忘记mysql用户密码时,怎么找回?
1. 关闭mariadb服务
systemctl stop mariadb
2. 跳过授权表
mysqld_safe --skip-grant-table &
3. 修改root密码
mysql
> update mysql.user set Password=password('westos') where User='root';
4. 关闭跳过授权表的进程,启动mariadb服务,使用新密码即可
ps aux | grep mysql
kill -9 pid
mysql -uroot -p
#5. mysql的备份与恢复
备份:
mysqldump -uroot -p mariadb >mariadb.dump
mysqldump -uroot -pwestos --no-data mariadb > `date +%Y_%m_%d`_mariadb.dump
mysqldump -uroot -pwestos --all-databases >mariadb4.dump
恢复:
mysqladmin -uroot -pwestos create mariadb2
mysql -uroot -pwestos mariadb2< mariadb.dump
#6. 通过网页管理数据库
********************************************************************************
***********************************http*****************************************
********************************************************************************
#1. http协议
超文本传输协议(hyper text transfer protocol),html(hyper text mark language)
## http一次事务的完整过程
client --请求报文--> server
client <--响应报文-- server
## Web资源
- 静态资源:png,html
- 动态资源:jsp.php
## 资源的定位
URL:http://172.25.254.88:80/phpadmin
#2. httpd的简单应用
## 安装与启动
yum install httpd -y
systemctl start httpd
systemctl enable httpd
systemctl stop firewalld
## 主配置文件/etc/httpd/conf/httpd.conf
###- 修改httpd服务默认端口
42 Listen 8080
###- 修改默认发布目录(注意selinux)
119 DocumentRoot "/westos/www/html"
124 <Directory "/westos/www">
125 AllowOverride None
126 # Allow open access:
127 Require all granted
128 </Directory>
163 <IfModule dir_module>
164 DirectoryIndex index.html westos.html
165 </IfModule>
- httpd帮助手册
yum install httpd-manual.noarch -y
访问:http://localhost/manual
###- 虚拟主机的建立
一台服务器,baidu.com,qq.com
1). httpd的端口改为80,默认发布目录改回去;
2). 创建不同域名访问不同信息的目录
mkdir /virtual/{qq.com,baidu.com}/html -p
echo "baidu'page" >/virtual/baidu.com/html/index.html
echo "qq'page" >/virtual/qq.com/html/index.html
3). 修改配置文件/etc/httpd/conf.d/目录下
cd /etc/httpd/conf.d/
vim virtual.conf
@@
1 <virtualhost *:80>
2 servername www.qq.com
3 serveralias qq.com
4 documentroot /virtual/qq.com/html
5 customlog "logs/qq.com.log" combined
6 </virtualhost>
7
8 <directory /virtual/qq.com >
9 require all granted
10 </directory>
@@
vim default.conf
@@
1 <virtualhost *:80>
2 documentroot /var/www/html
3 customlog "logs/default.log" combined
4 </virtualhost>
5 <directory /var/www>
6 require all granted
7 </directory>
@@
systemctl start httpd
5). 客户端一定要写解析/etc/hosts
172.25.xx.xx www.baidu.com www.qq.com www.sina.com
#3. linux+httpd+mysql+php
前提:已安装http,mariadb-server,php,php-mysql
1). 下载论坛的包到httpd的默认发布目录/var/www/html,并解压,然后包即可删除;
unzip Discuz_X2.5_SC_UTF8.zip -d /var/www/html/
2). 对解压生成的upload包重命名
mv /var/www/html/upload/ /var/www/html/mybbs
3). 网页访问http://ip/mybbs,进入安装论坛界面
4). 修改需要的权限
cd /var/www/html/mybbs
cp config/config_global_default.php config/config_global.php
cp config/config_ucenter_default.php config/config_ucenter.php
chmod 777 config -R
chmod 777 data -R
chmod 777 uc_client -R
chmod 777 uc_server -R
5). 填写关于数据库的信息
********************************mariadb**********************************************
*************************************************************************************
#1. 安装mysql
yum search mariadb //查找与mariadb有关的软件包
yum install mariadb mariadb-server -y //安装mariadb的server软件和client软件
## 启动mariadb服务
systemctl start mariadb
systemctl enable mariadb
## mariadb监听的端口
netstat -antlpe | grep mysql
ss -antlpe | grep mysql
vim /etc/services //所有服务与端口默认的对应关系
## 只允许本地连接,阻断所有来自网络的连接
vim /etc/my.cnf
skip-networking=1
systemctl restart mariadb
#2. mariadb的初始化
## 设置mysql的登陆密码
mysql_secure_installation
mysql -uroot -p
## mysql基本操作语句
show databases; //显示数据库,类似于目录,里面包含多个表
use mysql; //进入名称为mysql的数据库
show tables; //显示该数据库中的表
desc user; //显示表的结构
select * from user; //显示user表中的内容
select Host,User,Password from user; //显示表中某几列
create database westos; //创建以数据库名称为westos
create table westosuser( //创建一表
-> username varchar(10) not null,
-> passwd varchar(6) not null
-> );
insert into westosuser values ('user1','123'); //向表中插入内容
insert into westosuser(passwd,username) values("456","user2"); //按照指定顺序向表中插入数据
update westosuser set passwd='456' where username="user1"; //更新表中的内容
alter table westosuser add sex varchar(3); //添加sex列到westosuser表中
delete from westosuser where username="user1"; //删除表中用户名为user1的记录
drop table westosuser; //删除表
drop database westos; //删除数据库
## 用户和访问权限的操作
create user hello@localhost identified by 'hello';
//创建用户hello,可在本机登陆,密码为hello
create user hello@'%' identified by 'hello';
//创建用户hello,可在远程登陆,密码为hello
create database mariadb; //创建一数据库mariadb,对普通用户进行
grant all on mariadb.* to hello@localhost;
//给hello@localhost用户授权,如果为all,授权所有权限(insert,update,delete,select,create)
flush privileges; //刷新,重载授权表
show grants for hello@localhost; //查看用户授权
revoke delete,update on mariadb.* from hello@localhost;
//删除指定用户授权
drop user hello@localhost; //删除用户
#4. 忘记mysql用户密码时,怎么找回?
1. 关闭mariadb服务
systemctl stop mariadb
2. 跳过授权表
mysqld_safe --skip-grant-table &
3. 修改root密码
mysql
> update mysql.user set Password=password('westos') where User='root';
4. 关闭跳过授权表的进程,启动mariadb服务,使用新密码即可
ps aux | grep mysql
kill -9 pid
mysql -uroot -p
#5. mysql的备份与恢复
备份:
mysqldump -uroot -p mariadb >mariadb.dump
mysqldump -uroot -pwestos --no-data mariadb > `date +%Y_%m_%d`_mariadb.dump
mysqldump -uroot -pwestos --all-databases >mariadb4.dump
恢复:
mysqladmin -uroot -pwestos create mariadb2
mysql -uroot -pwestos mariadb2< mariadb.dump
#6. 通过网页管理数据库
********************************************************************************
***********************************http*****************************************
********************************************************************************
#1. http协议
超文本传输协议(hyper text transfer protocol),html(hyper text mark language)
## http一次事务的完整过程
client --请求报文--> server
client <--响应报文-- server
## Web资源
- 静态资源:png,html
- 动态资源:jsp.php
## 资源的定位
URL:http://172.25.254.88:80/phpadmin
#2. httpd的简单应用
## 安装与启动
yum install httpd -y
systemctl start httpd
systemctl enable httpd
systemctl stop firewalld
## 主配置文件/etc/httpd/conf/httpd.conf
###- 修改httpd服务默认端口
42 Listen 8080
###- 修改默认发布目录(注意selinux)
119 DocumentRoot "/westos/www/html"
124 <Directory "/westos/www">
125 AllowOverride None
126 # Allow open access:
127 Require all granted
128 </Directory>
163 <IfModule dir_module>
164 DirectoryIndex index.html westos.html
165 </IfModule>
- httpd帮助手册
yum install httpd-manual.noarch -y
访问:http://localhost/manual
###- 虚拟主机的建立
一台服务器,baidu.com,qq.com
1). httpd的端口改为80,默认发布目录改回去;
2). 创建不同域名访问不同信息的目录
mkdir /virtual/{qq.com,baidu.com}/html -p
echo "baidu'page" >/virtual/baidu.com/html/index.html
echo "qq'page" >/virtual/qq.com/html/index.html
3). 修改配置文件/etc/httpd/conf.d/目录下
cd /etc/httpd/conf.d/
vim virtual.conf
@@
1 <virtualhost *:80>
2 servername www.qq.com
3 serveralias qq.com
4 documentroot /virtual/qq.com/html
5 customlog "logs/qq.com.log" combined
6 </virtualhost>
7
8 <directory /virtual/qq.com >
9 require all granted
10 </directory>
@@
vim default.conf
@@
1 <virtualhost *:80>
2 documentroot /var/www/html
3 customlog "logs/default.log" combined
4 </virtualhost>
5 <directory /var/www>
6 require all granted
7 </directory>
@@
systemctl start httpd
5). 客户端一定要写解析/etc/hosts
172.25.xx.xx www.baidu.com www.qq.com www.sina.com
#3. linux+httpd+mysql+php
前提:已安装http,mariadb-server,php,php-mysql
1). 下载论坛的包到httpd的默认发布目录/var/www/html,并解压,然后包即可删除;
unzip Discuz_X2.5_SC_UTF8.zip -d /var/www/html/
2). 对解压生成的upload包重命名
mv /var/www/html/upload/ /var/www/html/mybbs
3). 网页访问http://ip/mybbs,进入安装论坛界面
4). 修改需要的权限
cd /var/www/html/mybbs
cp config/config_global_default.php config/config_global.php
cp config/config_ucenter_default.php config/config_ucenter.php
chmod 777 config -R
chmod 777 data -R
chmod 777 uc_client -R
chmod 777 uc_server -R
5). 填写关于数据库的信息