CentOS64+Qt+Mysql+ftp+无密钥传输的配置<详细过程>
2013-11-18 22:52
387 查看
这两天单位要部一个环境.CentOS64+Qt+Mysql+ftp+无密钥传输的.
有段日了没装系统了..命令忘的都差不多了..
############################################################################################
# 1. CentOS 配置yum源
############################################################################################
# 挂载两个ISO
将第一个盘的ISO1文件拷贝到ISO2中,进行挂载.
修改/etc/yum.repos.d/cetnos.repo
[base-centos]
name=CentOS
baseurl=file:///mnt/iso
gpgcheck=0
enabled=1
# 安装gcc,java
yum intall -y gcc*
yum intall -y java*
# 关闭防火墙
关闭:
chkconfig iptables off
selinuxenabled 0
############################################################################################
# 2. 安装MYSQL-5.1.66
############################################################################################
# 配置好yum源后,yum install -y mysql*
# 启动mysql
service mysqld start
mysql -h192.168.2.18 -uroot -p111
# 查看监听端口
netstat -tnlp |grep :3306
# 查看库
show databases;
# mysql的远程连接
# 在[mysqld]的段中加上一句:skip-grant-tables
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-name-resolve
skip-grant-tables
目的是为了:
跳过MySQL的访问控制,任何人都可以在控制台以管理员的身份进入MySQL数据库。
需要注意的是在修改完密码以后要把MySQL服务器停掉重新启动才会生效
重启mysql服务!
如果你想允许用户myuser从ip为192.168.1.3的主机连接到mysql服务器,并使用mypassword作为密码
GRANT ALL PRIVILEGES ON *.* TO
'myuser'@'192.168.1.3' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
############################################################################################
# 3. 编译安装Qt-4.5.2
############################################################################################
## Qt安装方法
解压安装包,并移动到 /user/locale/下面.
./configure -debug-and-release -fast -qt-sql-mysql -no-qt3support -no-webkit -no-opengl -no-openssl
# 配置结果
<注意:Qt默认只支持PNG图片,
如果有JPEG或其它格式,
需要去Qt的安装目录
plugins\imageformats
下拷贝图片插件>
Debug ............... no
Qt 3 compatibility .. no
QtDBus module ....... no
QtScriptTools module yes
QtXmlPatterns module yes
Phonon module ....... no
SVG module .......... yes
WebKit module ....... no
STL support ......... yes
PCH support ......... yes
MMX/3DNOW/SSE/SSE2.. yes/yes/yes/yes
Graphics System ..... default
IPv6 support ........ yes
IPv6 ifname support . yes
getaddrinfo support . yes
getifaddrs support .. yes
Accessibility ....... yes
NIS support ......... yes
CUPS support ........ no
Iconv support ....... yes
Glib support ........ no
GStreamer support ... no
Large File support .. yes
GIF support ......... plugin
TIFF support ........ plugin (qt)
JPEG support ........ plugin (qt)
PNG support ......... yes (qt)
MNG support ......... plugin (qt)
zlib support ........ system
Session management .. yes
OpenGL support ...... no
NAS sound support ... no
XShape support ...... yes
Xinerama support .... runtime
Xcursor support ..... runtime
Xfixes support ...... runtime
Xrandr support ...... runtime
Xrender support ..... yes
Xi support .......... runtime
MIT-SHM support ..... yes
FontConfig support .. yes
XKB Support ......... yes
immodule support .... yes
GTK theme support ... no
MySQL support ....... qt
SQLite support ...... plugin (qt)
OpenSSL support ..... no
## 编译安装
gmake && gmake install
## 修改环境变量
可以将环境变量添加到 .bashrc 或 .bash_profile 或 /etc/bashrc 或 /etc/profile
它们的区别是:
1. /etc/profile:对所有用户生效,当用户第一次登录时,该文件被执行.
2. /etc/bashrc:对所有用户生效,为每一个运行bash shell的用户执行此文件
3. ~/.bash_profile:仅会对当前用户有效,当用户登录时,该文件仅仅执行一次
4. ~/.bashrc:仅会对当前用户有效,当登录时以及每次打开新的shell时,该该文件被读取
QTDIR=/usr/local/qt-4.5.2
PATH=$QTDIR/bin:$PATH
LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
QMAKESPEC=$QTDIR/mkspecs/linux-g++-64
export QTDIR
export PATH
export LD_LIBRARY_PATH
export QMAKESPEC
## 查看Qt支持的图片类型
可以运行下面的函数查看:QImageReader::supportedImageFormats
QList<QByteArray> QImageReader::supportedImageFormats () [static]
Returns the list of image formats supported by QImageReader.
By default, Qt can read the following formats:
Format Description
BMP Windows Bitmap
GIF Graphic Interchange Format (optional)
JPG Joint Photographic Experts Group
JPEG Joint Photographic Experts Group
MNG Multiple-image Network Graphics
PNG Portable Network Graphics
PBM Portable Bitmap
PGM Portable Graymap
PPM Portable Pixmap
TIFF Tagged Image File Format
XBM X11 Bitmap
XPM X11 Pixmap
SVG Scalable Vector Graphics
TGA Targa Image Format
Reading and writing SVG files is supported through Qt's SVG Module.
TGA support only extends to reading non-RLE compressed files. In particular calls to capabilities for the tga plugin returns only QImageIOPlugin::CanRead, not QImageIOPlugin::CanWrite.
To configure Qt with GIF support, pass -qt-gif to the configure script or check the appropriate option in the graphical installer.
Note that the QApplication instance must be created before this function is called.
See also setFormat(), QImageWriter::supportedImageFormats(), and QImageIOPlugin.
############################################################################################
# 4. 使用Qt连接Mysql
############################################################################################
#include <QApplication>
#include <QtSql>
#include <QTableView>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("localhost");
db.setDatabaseName("mydb");
db.setUserName("username");
db.setPassword("password");
db.open();
QSqlQuery query;
query.exec("create table hello(id bigint not null auto_increment,name varchar(255),age bigint,primary key (id))");
query.exec("insert into hello(name, age) values('xiaoxi', 18)");
query.exec("insert into hello(name, age) values('xiaonan', 19)");
query.exec("insert into hello(name, age) values('xiaobei', 20)");
query.exec("insert into hello(name, age) values('xiaodong', 21)");
QSqlQueryModel *model = new QSqlQueryModel;
model->setQuery("select * from hello");
model->setHeaderData(0, Qt::Horizontal, "id");
model->setHeaderData(1, Qt::Horizontal, "name");
model->setHeaderData(2, Qt::Horizontal, "age");
QTableView *view = new QTableView;
view->setWindowTitle("QSqlQueryModel");
view->setModel(model);
view->show();
db.close();
return app.exec();
}
编译:
xhy@xhy-desktop:~$ qmake -project
xhy@xhy-desktop:~$ qmake
一定别忘了在工程的.pro文件里加上下面一行:
QT += sql
xhy@xhy-desktop:~$make
xhy@xhy-desktop:~$./mysql
############################################################################################
# 5. CentOS配置sftp
############################################################################################
sftp是ssh内含的协议,只要sshd服务器启动了,它就可用.
sftp root@192.168.2.18
>ls
>get ...
>put ...
如果sshd服务没有默认启动:
chkconfig sshd on
############################################################################################
# 6. CentOS配置无密钥传输
############################################################################################
# 举例说明:
[root@centos6-64 .ssh]# pwd
/root/.ssh
[root@centos6-64 .ssh]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
d6:2a:df:0b:46:3d:22:da:5b:24:b2:da:78:01:f3:c4
root@centos6-64
The key's randomart image is:
+--[ RSA 2048]----+
| |
| |
| . |
| o E o |
| =. o S + |
| o= * o . |
| o.o = |
| +. * o |
| o.. . . o. |
+-----------------+
[root@centos6-64 .ssh]# ls -lrt
total 16
-rw-r--r-- 1 root root 394 Nov 18 16:18 known_hosts
-rw-r--r-- 1 root root 394 Nov 18 22:32 authorized_keys
-rw-r--r-- 1 root root 397 Nov 18 22:33 id_rsa.pub
-rw------- 1 root root 1675 Nov 18 22:33 id_rsa
[root@centos6-64 ~]# ssh-copy-id 192.168.2.16
root@192.168.2.16's password:
Now try logging into the machine, with "ssh '192.168.2.16'", and check in:
.ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.
<成功>
[root@centos6-64 ~]# ssh 192.168.2.16
Last login: Mon Nov 25 10:10:24 2013 from 192.168.2.166
[root@www ~]#
有段日了没装系统了..命令忘的都差不多了..
############################################################################################
# 1. CentOS 配置yum源
############################################################################################
# 挂载两个ISO
将第一个盘的ISO1文件拷贝到ISO2中,进行挂载.
开机自动挂载光盘 修改/etc/fstab tmpfs /dev/shm tmpfs defaults 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0 sysfs /sys sysfs defaults 0 0 proc /proc proc defaults 0 0 /root/centos64.iso /mnt/iso iso9660 defaults,ro,loop 0 0 mkdir /mnt/iso 手动挂载光盘 mount -o loop -t iso9660 /root/centos64.iso /mnt/iso
修改/etc/yum.repos.d/cetnos.repo
[base-centos]
name=CentOS
baseurl=file:///mnt/iso
gpgcheck=0
enabled=1
# 安装gcc,java
yum intall -y gcc*
yum intall -y java*
# 关闭防火墙
关闭:
chkconfig iptables off
selinuxenabled 0
############################################################################################
# 2. 安装MYSQL-5.1.66
############################################################################################
# 配置好yum源后,yum install -y mysql*
# 启动mysql
service mysqld start
mysql -h192.168.2.18 -uroot -p111
# 查看监听端口
netstat -tnlp |grep :3306
# 查看库
show databases;
# mysql的远程连接
# 在[mysqld]的段中加上一句:skip-grant-tables
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-name-resolve
skip-grant-tables
目的是为了:
跳过MySQL的访问控制,任何人都可以在控制台以管理员的身份进入MySQL数据库。
需要注意的是在修改完密码以后要把MySQL服务器停掉重新启动才会生效
重启mysql服务!
如果你想允许用户myuser从ip为192.168.1.3的主机连接到mysql服务器,并使用mypassword作为密码
GRANT ALL PRIVILEGES ON *.* TO
'myuser'@'192.168.1.3' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
############################################################################################
# 3. 编译安装Qt-4.5.2
############################################################################################
## Qt安装方法
解压安装包,并移动到 /user/locale/下面.
./configure -debug-and-release -fast -qt-sql-mysql -no-qt3support -no-webkit -no-opengl -no-openssl
# 配置结果
<注意:Qt默认只支持PNG图片,
如果有JPEG或其它格式,
需要去Qt的安装目录
plugins\imageformats
下拷贝图片插件>
Debug ............... no
Qt 3 compatibility .. no
QtDBus module ....... no
QtScriptTools module yes
QtXmlPatterns module yes
Phonon module ....... no
SVG module .......... yes
WebKit module ....... no
STL support ......... yes
PCH support ......... yes
MMX/3DNOW/SSE/SSE2.. yes/yes/yes/yes
Graphics System ..... default
IPv6 support ........ yes
IPv6 ifname support . yes
getaddrinfo support . yes
getifaddrs support .. yes
Accessibility ....... yes
NIS support ......... yes
CUPS support ........ no
Iconv support ....... yes
Glib support ........ no
GStreamer support ... no
Large File support .. yes
GIF support ......... plugin
TIFF support ........ plugin (qt)
JPEG support ........ plugin (qt)
PNG support ......... yes (qt)
MNG support ......... plugin (qt)
zlib support ........ system
Session management .. yes
OpenGL support ...... no
NAS sound support ... no
XShape support ...... yes
Xinerama support .... runtime
Xcursor support ..... runtime
Xfixes support ...... runtime
Xrandr support ...... runtime
Xrender support ..... yes
Xi support .......... runtime
MIT-SHM support ..... yes
FontConfig support .. yes
XKB Support ......... yes
immodule support .... yes
GTK theme support ... no
MySQL support ....... qt
SQLite support ...... plugin (qt)
OpenSSL support ..... no
## 编译安装
gmake && gmake install
## 修改环境变量
可以将环境变量添加到 .bashrc 或 .bash_profile 或 /etc/bashrc 或 /etc/profile
它们的区别是:
1. /etc/profile:对所有用户生效,当用户第一次登录时,该文件被执行.
2. /etc/bashrc:对所有用户生效,为每一个运行bash shell的用户执行此文件
3. ~/.bash_profile:仅会对当前用户有效,当用户登录时,该文件仅仅执行一次
4. ~/.bashrc:仅会对当前用户有效,当登录时以及每次打开新的shell时,该该文件被读取
QTDIR=/usr/local/qt-4.5.2
PATH=$QTDIR/bin:$PATH
LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
QMAKESPEC=$QTDIR/mkspecs/linux-g++-64
export QTDIR
export PATH
export LD_LIBRARY_PATH
export QMAKESPEC
## 查看Qt支持的图片类型
可以运行下面的函数查看:QImageReader::supportedImageFormats
QList<QByteArray> QImageReader::supportedImageFormats () [static]
Returns the list of image formats supported by QImageReader.
By default, Qt can read the following formats:
Format Description
BMP Windows Bitmap
GIF Graphic Interchange Format (optional)
JPG Joint Photographic Experts Group
JPEG Joint Photographic Experts Group
MNG Multiple-image Network Graphics
PNG Portable Network Graphics
PBM Portable Bitmap
PGM Portable Graymap
PPM Portable Pixmap
TIFF Tagged Image File Format
XBM X11 Bitmap
XPM X11 Pixmap
SVG Scalable Vector Graphics
TGA Targa Image Format
Reading and writing SVG files is supported through Qt's SVG Module.
TGA support only extends to reading non-RLE compressed files. In particular calls to capabilities for the tga plugin returns only QImageIOPlugin::CanRead, not QImageIOPlugin::CanWrite.
To configure Qt with GIF support, pass -qt-gif to the configure script or check the appropriate option in the graphical installer.
Note that the QApplication instance must be created before this function is called.
See also setFormat(), QImageWriter::supportedImageFormats(), and QImageIOPlugin.
############################################################################################
# 4. 使用Qt连接Mysql
############################################################################################
#include <QApplication>
#include <QtSql>
#include <QTableView>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("localhost");
db.setDatabaseName("mydb");
db.setUserName("username");
db.setPassword("password");
db.open();
QSqlQuery query;
query.exec("create table hello(id bigint not null auto_increment,name varchar(255),age bigint,primary key (id))");
query.exec("insert into hello(name, age) values('xiaoxi', 18)");
query.exec("insert into hello(name, age) values('xiaonan', 19)");
query.exec("insert into hello(name, age) values('xiaobei', 20)");
query.exec("insert into hello(name, age) values('xiaodong', 21)");
QSqlQueryModel *model = new QSqlQueryModel;
model->setQuery("select * from hello");
model->setHeaderData(0, Qt::Horizontal, "id");
model->setHeaderData(1, Qt::Horizontal, "name");
model->setHeaderData(2, Qt::Horizontal, "age");
QTableView *view = new QTableView;
view->setWindowTitle("QSqlQueryModel");
view->setModel(model);
view->show();
db.close();
return app.exec();
}
编译:
xhy@xhy-desktop:~$ qmake -project
xhy@xhy-desktop:~$ qmake
一定别忘了在工程的.pro文件里加上下面一行:
QT += sql
xhy@xhy-desktop:~$make
xhy@xhy-desktop:~$./mysql
############################################################################################
# 5. CentOS配置sftp
############################################################################################
sftp是ssh内含的协议,只要sshd服务器启动了,它就可用.
sftp root@192.168.2.18
>ls
>get ...
>put ...
如果sshd服务没有默认启动:
chkconfig sshd on
############################################################################################
# 6. CentOS配置无密钥传输
############################################################################################
# 举例说明:
[root@centos6-64 .ssh]# pwd
/root/.ssh
[root@centos6-64 .ssh]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
d6:2a:df:0b:46:3d:22:da:5b:24:b2:da:78:01:f3:c4
root@centos6-64
The key's randomart image is:
+--[ RSA 2048]----+
| |
| |
| . |
| o E o |
| =. o S + |
| o= * o . |
| o.o = |
| +. * o |
| o.. . . o. |
+-----------------+
[root@centos6-64 .ssh]# ls -lrt
total 16
-rw-r--r-- 1 root root 394 Nov 18 16:18 known_hosts
-rw-r--r-- 1 root root 394 Nov 18 22:32 authorized_keys
-rw-r--r-- 1 root root 397 Nov 18 22:33 id_rsa.pub
-rw------- 1 root root 1675 Nov 18 22:33 id_rsa
[root@centos6-64 ~]# ssh-copy-id 192.168.2.16
root@192.168.2.16's password:
Now try logging into the machine, with "ssh '192.168.2.16'", and check in:
.ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.
<成功>
[root@centos6-64 ~]# ssh 192.168.2.16
Last login: Mon Nov 25 10:10:24 2013 from 192.168.2.166
[root@www ~]#
相关文章推荐
- <车载物联网项目,视频采集传输部分,第一天> FFmpeg的安装过程
- USB枚举过程的详细分析&lt;转&gt;
- struts开发<struts中的action详细配置. 二>
- squid 配置二级代理< redhat9>---轻松配置
- Mybatis IBatis的Mapper配置文件中使用大于号好小于号 :>和<
- 关于Spring中的<context:annotation-config/>配置
- HttpWebResponse 传输IDictionary<string, string>[] parameter数组
- C语言第四天课堂笔记<详细+注释>
- 配置Spring <context:annotation-config/>的作用
- 使用<appSettings>元素定义配置参数
- [原]java专业程序代写(qq:928900200),学习笔记之基础入门<Hibernate_配置详解>(三十六)
- 只有在配置文件或 Page 指令中将 enableSessionState 设置为 true 时,才能使用会话状态。还请确保在应用程序配置的 <configuration>
- Mahout安装与配置<转>
- 关于Spring中的<context:annotation-config/>配置
- cocos2d-x基础<一> Android环境配置和HelloWorld的运行
- Spring的配置文件applicationContext.xml中的 <context:component-scan base-package="com.orm" />
- 配置错误<location allowOverride="false">
- 由于内部错误,服务器无法处理该请求。有关该错误的详细信息,请打开服务器上的 IncludeExceptionDetailInFaults (从 ServiceBehaviorAttribute 或从 <serviceDebug> 配置行为)以便将异常信息发送回客户端,
- 如何成为一个游戏制作人——第三章:过程式编程语法(详细请自学<<C++Primer>>)
- rhel_rsync详细配置<三>rsync服务器配置