注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

God is U 做自己的上帝

富原孤島--只发优质级的文章

 
 
 

日志

 
 

Redhat7 安装配置apache/mariadb/python3/pymysql3  

2017-02-03 14:11:59|  分类: [LINUX] |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
1、Redhat 7.2安装和配置apache
$vi /etc/yum.repos.d/Redhat7.repo
[Rh7.2yum]
name=Rh7.2yum
baseurl=ftp://<可用的Yum源IP>/pub/
enabled=1
gpgcheck=0
$yum repolist
$yum search httpd
$rpm -qa httpd
$yum install httpd
$systemctl status httpd
$systemctl start httpd
$systemctl enable httpd

$yum search  netstat
$yum install net-tools
$netstat -tunpl
$lsmod |grep ipv6
$vi /etc/sysctl.conf
sysctl -w net.ipv6.conf.all.disable_ipv6=1
sysctl -w net.ipv6.conf.default.disable_ipv6=1
$sysctl -p
$systemctl is-active httpd
$apachectl configtest
$vi /etc/httpd/conf/httpd.conf 
Servername=<本机ip>
$systemctl restart httpd
$systemctl is-active httpd
$netstat -tunpl

$cat welcome.conf 
$vi /var/www/html/index.html
$firewall-cmd --add-service http
$firewall-cmd --add-service https
$firewall-cmd --reload

2、Redhat 7.2安装和配置mysql(mariadb)
$vi /etc/yum.repos.d/MariaDB.repo
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/rhel7-amd64/
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
$yum install MariaDB-server MariaDB-client
$systemctl start mariadb
$systemctl enable mariadb
$systemctl status mariadb
$mysql_secure_installation
y y y y y 
$firewall-cmd --permanent --add-service=mysql
$firewall-cmd --reload

$mysql -u root -p
>show databases;
>create database python;
>use python;
>show tables;
>create table mybook(name char(15),price int,pages int);
>show tables;
>describe mybook;
>insert into mybook(name,price,pages) values(‘LinuxHB’,‘128’,898);
>insert into mybook(name,price,pages) values(‘UnixHB’,‘68’,569);
>insert into mybook(name,price,pages) values(‘Python3HB’,‘100’,968);
>select * from mybook;
>select * from mybook where price>100;
>select * from mybook where price!=100;
>exit

3、Redhat 7.2备份和恢复mysql(mariadb)
$mysqldump -u root -p python >/root/python.dump
$ll
$mysql -u root -p
>drop database python;
>create database python;
>exit;
$mysql -u root -p python < /root/python.dump
$mysql -u root -p
>use python;
>show tables;
4、Redhat 7.2配置mysql(mariadb)用户权限
$mysql -u root -p
>create user python@localhost IDENTIFIED BY '123456';
>use mysql;
>select host,user,password from user;
>exit;
$mysql -u python -p
>show grants for python@localhost;
>show databases;
>exit;
$mysql -u root -p
>show grants for python@localhost;
>grant select,update,insert on python.* to python@localhost;
.....
>revoke update,insert on python.* from  python@localhost;
>show grants for python@localhost;
>exit;
5、Redhat 7.2安装python34
$rpm -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm
$yum search python34
$yum install python34
$python3 --version

6、Redhat 7.2安装python3的SQL连接器
$wget https://pypi.python.org/packages/source/P/PyMySQL3/PyMySQL3-0.5.tar.gz
$tar -xf PyMySQL3-0.5.tar.gz
$cd PyMySQL3-0.5
$python3 setup.py install
$python3
>>> import pymysql
>>> conn=pymysql.connect(host='localhost',user='root',passwd='falwpa',db='python',charset='utf8')
>>> cur=conn.cursor()
>>> for i in cur:
...     print(i)
... 
('PythonHB', 100, 2356)
('PythonHB', 168, 2356)
('PythonHB', 168, 2356)
('PythonHB', 168, 266)
>>> cur.close()
>>> conn.close()

  评论这张
 
阅读(72)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017