【2018年6月24日 22:55:47】
VM7+CentOS5.5使用NAT方式连接互联网
1、在VMWare的菜单:“VM→Setting...”
2、在VMWare的菜单:“Edit→Virtual Network Edit...”,在弹出的对话框中单击“Restore default”。并且将“Subnet IP”设置成为:"192.168.126.0"(这个IP可以自定义),
再单击“NAt Settings...”
在CentOS:
查看IP地址:
# ip addr show
·修改网卡设置:
# vim /etc/sysconfig/network-scripts/ifcfg-eth0
修改内容(192.168.126.x:x取值0~255):
IPADDR=192.168.126.18
重启网卡:service network restart。此时就可以使用XShell连接Linux了。
ping路由
# ping 192.168.126.1
# ping 192.168.126.2
添加网关:
# vim /etc/sysconfig/network-scripts/route-eth0
内容如下:
0.0.0.0/0 via 192.168.126.2 dev eth0
重启网卡:
# service network restart
设置DNS:
# vim /etc/resolv.conf
内容如下:
nameserver 192.168.126.2
#nameserver 175.188.160.154
#meserver 175.188.160.254
#search localdomain
此时,就可ping同外网了。ping www.baidu.com。
【2018年6月30日 09:45:50】
查看IP地址:ip addr show
[root@localhost ~]# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:1d:8f:97 brd ff:ff:ff:ff:ff:ff
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 52:54:00:33:18:72 brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000
link/ether 52:54:00:33:18:72 brd ff:ff:ff:ff:ff:ff
“2:”的是网卡
如果是CentOS7,修改网卡设置如下:
vim /etc/sysconfig/network-scripts/ifcfg-ens33
需要修改内容如下,将“BOOTPROTO=dhcp”改为:“BOOTPROTO=static”、“ONBOOT=no”改为:“ONBOOT=yes”,其他三项直接添加。
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.126.28
NETMASK=225.225.225.0
GATEWAY=192.168.126.2
此时,重启网卡(service network restart)可以用XShell连接Linux了。再将DNS设置与CentOS6一样
vi /etc/resolv.conf
添加:nameserver 192.168.126.2
# Generated by NetworkManager
nameserver 192.168.126.2
wq保存退出。此时就可以ping通了。
[root@localhost ~]# ping www.baidu.com
PING www.a.shifen.com (39.156.66.14) 56(84) bytes of data.
64 bytes from 39.156.66.14 (39.156.66.14): icmp_seq=1 ttl=128 time=43.8 ms
64 bytes from 39.156.66.14 (39.156.66.14): icmp_seq=2 ttl=128 time=27.9 ms
64 bytes from 39.156.66.14 (39.156.66.14): icmp_seq=3 ttl=128 time=40.5 ms
^C
--- www.a.shifen.com ping statistics ---
15 packets transmitted, 15 received, 0% packet loss, time 14036ms
rtt min/avg/max/mdev = 25.443/35.052/43.864/5.365 ms
如果无法ping通百度,请关闭关闭selinux和防火墙:
# vi /etc/selinux/config
内容如下:
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
# SELINUX=enforcing
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
将“SELINUX=enforcing”改为“SELINUX=disabled”重启后永久关闭selinux。
# 查看selinux的状态
# sestatus -v
# 这个命令可以临时关闭selinux
# setenforce 0
关闭防火墙:
# 这个命令可以临时关闭防火墙
# service iptables stop
# service ip6tables stop
# 这个命令可以永久关闭防火墙
# chkconfig iptables off
# chkconfig ip6tables off
# 这个命令可以查看防火墙的状态
# chkconfig iptables --list
# chkconfig ip6tables --list
下面是具体过程:
[root@localhost ~]# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:0c:29:27:db:e0 brd ff:ff:ff:ff:ff:ff
inet 192.168.126.18/24 brd 222.190.30.255 scope global eth0
inet6 fe80::20c:29ff:fe27:dbe0/64 scope link
valid_lft forever preferred_lft forever
3: sit0: <NOARP> mtu 1480 qdisc noop
link/sit 0.0.0.0 brd 0.0.0.0
[root@localhost ~]# ping 192.168.126.1
PING 192.168.126.1 (192.168.126.1) 56(84) bytes of data.
64 bytes from 192.168.126.1: icmp_seq=1 ttl=64 time=0.369 ms
64 bytes from 192.168.126.1: icmp_seq=2 ttl=64 time=0.612 ms --- 192.168.126.1 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.369/0.490/0.612/0.123 ms
[root@localhost ~]# ping 192.168.126.2
PING 192.168.126.2 (192.168.126.2) 56(84) bytes of data.
64 bytes from 192.168.126.2: icmp_seq=1 ttl=128 time=0.437 ms
64 bytes from 192.168.126.2: icmp_seq=2 ttl=128 time=0.578 ms --- 192.168.126.2 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 0.437/0.507/0.578/0.074 ms
[root@localhost ~]# vim /etc/sysconfig/network-scripts/route-eth0
[root@localhost ~]# service network restart
[root@localhost ~]# ip route show
192.168.126.0/24 dev eth0 proto kernel scope link src 192.168.126.18
169.254.0.0/16 dev eth0 scope link
default via 192.168.126.2 dev eth0
[root@localhost ~]# vim /etc/resolv.conf
具体原理分析:
检测是否可以ping通外网:ping www.baidu.com -c 10 | awk '{ print $0"\t" strftime("%Y-%m-%d %H:%M:%S",systime())}'
[root@localhost java]# ping www.baidu.com -c 10 | awk '{ print $0"\t" strftime("%Y-%m-%d %H:%M:%S",systime())}'
PING www.a.shifen.com (119.75.213.61) 56(84) bytes of data. 2018-06-25 16:51:49
64 bytes from 127.0.0.1 (119.75.213.61): icmp_seq=1 ttl=128 time=9.37 ms 2018-06-25 16:51:49
64 bytes from 127.0.0.1 (119.75.213.61): icmp_seq=2 ttl=128 time=7.96 ms 2018-06-25 16:51:50
64 bytes from 127.0.0.1 (119.75.213.61): icmp_seq=3 ttl=128 time=8.57 ms 2018-06-25 16:51:51
64 bytes from 127.0.0.1 (119.75.213.61): icmp_seq=4 ttl=128 time=10.8 ms 2018-06-25 16:51:52
Java的jdk的安装(rpm方式):
[root@localhost ~]# mkdir /usr/local/src/java
[root@localhost ~]# cd /usr/local/src/java
[root@localhost java]# rpm -ivh jdk-8u151-linux-x64.rpm
Preparing... ########################################### [100%]
1:jdk1.8 ########################################### [100%]
Unpacking JAR files...
tools.jar...
plugin.jar...
javaws.jar...
deploy.jar...
rt.jar...
jsse.jar...
charsets.jar...
localedata.jar...
[root@localhost java]# java -version
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)
安装tomcat
[root@localhost ~]# mkdir /usr/local/tomcat
[root@localhost ~]cd /usr/local/tomcat
[root@localhost tomcat]tar -zxvf apache-tomcat-8.5.9.tar.gz
[root@localhost tomcat]cd apache-tomcat-8.5.9/bin
[root@localhost bin]# ./startup.sh
Using CATALINA_BASE: /usr/local/tomcat/apache-tomcat-8.5.9
Using CATALINA_HOME: /usr/local/tomcat/apache-tomcat-8.5.9
Using CATALINA_TMPDIR: /usr/local/tomcat/apache-tomcat-8.5.9/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/tomcat/apache-tomcat-8.5.9/bin/bootstrap.jar:/usr/local/tomcat/apache-tomcat-8.5.9/bin/tomcat-juli.jar
Tomcat started.
升级yum:
# 只升级所有包,不升级软件和系统内核
[root@localhost ~]# yum -y upgrade
# 升级所有包同时也升级软件和系统内核
[root@localhost ~]# yum -y update
在线安装vim:
# yum -y install vim
具体安装过程:
[root@localhost ~]# yum search vim
Loaded plugins: fastestmirror
http://ftp.sjtu.edu.cn/centos/6.9/os/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 7 - "Failed to connect to 2001:da8:8000:6023::230: Network is unreachable"
Trying other mirror.
base | 3.7 kB 00:00
base/primary_db | 4.7 MB 00:00
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=extras&infra=stock error was
12: Timeout on http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=extras&infra=stock: (28, 'Operation too slow. Less than 1 bytes/sec transfered the last 30 seconds')
Error: Cannot retrieve repository metadata (repomd.xml) for repository: extras. Please verify its path and try again
[root@localhost ~]# yum -y install vim
Loaded plugins: fastestmirror
Setting up Install Process
Determining fastest mirrors
* base: mirrors.huaweicloud.com
* extras: mirrors.huaweicloud.com
* updates: mirrors.huaweicloud.com
extras | 3.4 kB 00:00
extras/primary_db | 30 kB 00:00
updates | 3.4 kB 00:00
updates/primary_db | 8.1 MB 00:12
Resolving Dependencies
--> Running transaction check
---> Package vim-enhanced.x86_64 2:7.4.629-5.el6_8.1 will be installed
--> Processing Dependency: vim-common = 2:7.4.629-5.el6_8.1 for package: 2:vim-enhanced-7.4.629-5.el6_8.1.x86_64
--> Processing Dependency: libgpm.so.2()(64bit) for package: 2:vim-enhanced-7.4.629-5.el6_8.1.x86_64
--> Running transaction check
---> Package gpm-libs.x86_64 0:1.20.6-12.el6 will be installed
---> Package vim-common.x86_64 2:7.4.629-5.el6_8.1 will be installed
--> Processing Dependency: vim-filesystem for package: 2:vim-common-7.4.629-5.el6_8.1.x86_64
--> Running transaction check
---> Package vim-filesystem.x86_64 2:7.4.629-5.el6_8.1 will be installed
--> Finished Dependency Resolution Dependencies Resolved =======================================================================================================
Package Arch Version Repository Size
=======================================================================================================
Installing:
vim-enhanced x86_64 2:7.4.629-5.el6_8.1 base 1.0 M
Installing for dependencies:
gpm-libs x86_64 1.20.6-12.el6 base 28 k
vim-common x86_64 2:7.4.629-5.el6_8.1 base 6.7 M
vim-filesystem x86_64 2:7.4.629-5.el6_8.1 base 15 k Transaction Summary
=======================================================================================================
Install 4 Package(s) Total download size: 7.8 M
Installed size: 23 M
Downloading Packages:
(1/4): gpm-libs-1.20.6-12.el6.x86_64.rpm | 28 kB 00:00
(2/4): vim-common-7.4.629-5.el6_8.1.x86_64.rpm | 6.7 MB 00:09
(3/4): vim-enhanced-7.4.629-5.el6_8.1.x86_64.rpm | 1.0 MB 00:01
(4/4): vim-filesystem-7.4.629-5.el6_8.1.x86_64.rpm | 15 kB 00:00
-------------------------------------------------------------------------------------------------------
Total 682 kB/s | 7.8 MB 00:11
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Importing GPG key 0xC105B9DE:
Userid : CentOS-6 Key (CentOS 6 Official Signing Key) <centos-6-key@centos.org>
Package: centos-release-6-8.el6.centos.12.3.x86_64 (@anaconda-CentOS-201605220104.x86_64/6.8)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
Installing : gpm-libs-1.20.6-12.el6.x86_64 1/4
Installing : 2:vim-filesystem-7.4.629-5.el6_8.1.x86_64 2/4
Installing : 2:vim-common-7.4.629-5.el6_8.1.x86_64 3/4
Installing : 2:vim-enhanced-7.4.629-5.el6_8.1.x86_64 4/4
Verifying : 2:vim-enhanced-7.4.629-5.el6_8.1.x86_64 1/4
Verifying : 2:vim-filesystem-7.4.629-5.el6_8.1.x86_64 2/4
Verifying : 2:vim-common-7.4.629-5.el6_8.1.x86_64 3/4
Verifying : gpm-libs-1.20.6-12.el6.x86_64 4/4 Installed:
vim-enhanced.x86_64 2:7.4.629-5.el6_8.1 Dependency Installed:
gpm-libs.x86_64 0:1.20.6-12.el6 vim-common.x86_64 2:7.4.629-5.el6_8.1
vim-filesystem.x86_64 2:7.4.629-5.el6_8.1 Complete!
在线安装wget:
# yum -y install wget
在线安装git:
# yum install git
安装docker
[root@localhost ~]# yum install docker
[root@localhost ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
centos7查看端口是否开放:https://jingyan.baidu.com/article/9113f81b4713252b3214c788.html
1、添加开放端口:
[root@localhost ~]# firewall-cmd --zone=public --add-port=80/tcp --permanent && firewall-cmd --zone=public --add-port=90/tcp --permanent && firewall-cmd --zone=public --add-port=3306/tcp --permanent && firewall-cmd --zone=public --add-port=3307/tcp --permanent && firewall-cmd --zone=public --add-port=5637/tcp --permanent && firewall-cmd --zone=public --add-port=1521/tcp --permanent && firewall-cmd --zone=public --add-port=15672/tcp --permanent && firewall-cmd --zone=public --add-port=27017/tcp --permanent
[root@localhost ~]# firewall-cmd --zone=public --add-port=80/tcp --permanent && firewall-cmd --zone=public --add-port=90/tcp --permanent && firewall-cmd --zone=public --add-port=3306/tcp --permanent && firewall-cmd --zone=public --add-port=3307/tcp --permanent && firewall-cmd --zone=public --add-port=5637/tcp --permanent && firewall-cmd --zone=public --add-port=1521/tcp --permanent && firewall-cmd --zone=public --add-port=15672/tcp --permanent && firewall-cmd --zone=public --add-port=27017/tcp --permanent
success
success
success
success
success
success
success
success
2、重载防火墙:firewall-cmd --reload
[root@localhost ~]# firewall-cmd --reload
success
3、查看防火墙开放端口:iptables-save
[root@localhost ~]# iptables-save
-A IN_public_allow -p tcp -m tcp --dport 22 -m conntrack --ctstate NEW -j ACCEPT
-A IN_public_allow -p tcp -m tcp --dport 80 -m conntrack --ctstate NEW -j ACCEPT
-A IN_public_allow -p tcp -m tcp --dport 443 -m conntrack --ctstate NEW -j ACCEPT
-A IN_public_allow -p tcp -m tcp --dport 3306 -m conntrack --ctstate NEW -j ACCEPT
-A IN_public_allow -p tcp -m tcp --dport 3307 -m conntrack --ctstate NEW -j ACCEPT
4、显示出当前主机打开的所有端口:netstat -tlunp
[root@localhost ~]# netstat -tlunp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 705/rpcbind
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 3506/dnsmasq
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1122/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1130/cupsd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2676/master
tcp6 0 0 :::111 :::* LISTEN 705/rpcbind
tcp6 0 0 :::22 :::* LISTEN 1122/sshd
tcp6 0 0 ::1:631 :::* LISTEN 1130/cupsd
tcp6 0 0 ::1:25 :::* LISTEN 2676/master
udp 0 0 0.0.0.0:878 0.0.0.0:* 705/rpcbind
udp 0 0 0.0.0.0:5353 0.0.0.0:* 718/avahi-daemon: r
udp 0 0 0.0.0.0:38593 0.0.0.0:* 718/avahi-daemon: r
udp 0 0 192.168.122.1:53 0.0.0.0:* 3506/dnsmasq
udp 0 0 0.0.0.0:67 0.0.0.0:* 3506/dnsmasq
udp 0 0 0.0.0.0:111 0.0.0.0:* 705/rpcbind
udp6 0 0 :::878 :::* 705/rpcbind
udp6 0 0 :::111 :::* 705/rpcbind
【2019年6月27日 10:59:09】
CentOS命令修改系统时间同步
[root@localhost ~]# date
Thu Jun 27 18:53:21 CST 2019
[root@localhost ~]# hwclock --show
Thu 27 Jun 2019 06:54:09 PM CST -0.128977 seconds
[root@localhost ~]# hwclock --set --date '2019-06-27 10:55:30'
[root@localhost ~]# hwclock --show
Thu 27 Jun 2019 10:55:35 AM CST -0.146720 seconds
[root@localhost ~]# hwclock --hctosy
[root@localhost ~]# clock -w
[root@localhost ~]# init 0
【2019年7月12日 14:24:15】
CentOS安装nmap端口查看工具:yum install nmap
[root@localhost ~]# rpm -qa | grep nmap
nmap-ncat-6.40-16.el7.x86_64
[root@localhost ~]# yum install nmap
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.163.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
docker-ce-stable | 3.5 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
updates/7/x86_64/primary_db | 6.5 MB 00:00:03
Resolving Dependencies
--> Running transaction check
---> Package nmap.x86_64 2:6.40-16.el7 will be installed
--> Processing Dependency: nmap-ncat = 2:6.40-16.el7 for package: 2:nmap-6.40-16.el7.x86_64
--> Running transaction check
---> Package nmap-ncat.x86_64 2:6.40-13.el7 will be updated
---> Package nmap-ncat.x86_64 2:6.40-16.el7 will be an update
--> Finished Dependency Resolution Dependencies Resolved ================================================================================================================================================================================
Package Arch Version Repository Size
================================================================================================================================================================================
Installing:
nmap x86_64 2:6.40-16.el7 base 3.9 M
Updating for dependencies:
nmap-ncat x86_64 2:6.40-16.el7 base 206 k Transaction Summary
================================================================================================================================================================================
Install 1 Package
Upgrade ( 1 Dependent package) Total download size: 4.2 M
Is this ok [y/d/N]: y
Downloading packages:
No Presto metadata available for base
(1/2): nmap-ncat-6.40-16.el7.x86_64.rpm | 206 kB 00:00:00
(2/2): nmap-6.40-16.el7.x86_64.rpm | 3.9 MB 00:00:01
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 4.0 MB/s | 4.2 MB 00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : 2:nmap-ncat-6.40-16.el7.x86_64 1/3
Installing : 2:nmap-6.40-16.el7.x86_64 2/3
Cleanup : 2:nmap-ncat-6.40-13.el7.x86_64 3/3
Verifying : 2:nmap-ncat-6.40-16.el7.x86_64 1/3
Verifying : 2:nmap-6.40-16.el7.x86_64 2/3
Verifying : 2:nmap-ncat-6.40-13.el7.x86_64 3/3 Installed:
nmap.x86_64 2:6.40-16.el7 Dependency Updated:
nmap-ncat.x86_64 2:6.40-16.el7 Complete!
【Mon Jul 03 2017 17:50:16 GMT+0800】
Linux下编译安装mysql-5.5.20.tar.gz
(1)创建MySQL安装目录
[root@localhost ~]# mkdir -p /usr/local/mysql/
(2)创建数据存放目录
[root@localhost ~]# mkdir -p /usr/data/mysql/
(3)创建用户及用户组和赋予数据存放目录权限
[root@localhost ~]# groupadd mysql
[root@localhost ~]# useradd -g mysql mysql
[root@localhost ~]# chown mysql.mysql -R /usr/data/mysql/
------Start Copy------
groupadd mysql
useradd -g mysql mysql
chown mysql.mysql -R /usr/data/mysql/
------End Copy------
(4)cmake(MySQL5.5以后是通过cmake来编译的)
下载:wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz
解压:tar zxvf cmake-2.8.4.tar.gz
cd cmake-2.8.4
安装:./configure make && make install
[root@localhost mnt]# tar zxvf cmake-2.8.4.tar.gz
[root@localhost mnt]# cd cmake-2.8.4
[root@localhost cmake-2.8.4]# ./configure make && make install
------Start Copy------
tar zxvf cmake-2.8.4.tar.gz
cd cmake-2.8.4
./configure make && make install
------End Copy------
(5)解压mysql-5.5.20.tar.gz
[root@localhost mnt]# tar zxvf mysql-5.5.20.tar.gz
[root@localhost mnt]# cd mysql-5.5.20
------Start Copy------
tar zxvf mysql-5.5.20.tar.gz
cd mysql-5.5.20
------End Copy------
(6)编译mysql-5.5.20
[root@localhost mysql-5.5.20]#
------Start Copy------
cmake . \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql/ \
-DMYSQL_DATADIR=/usr/data/mysql \
-DMYSQL_UNIX_ADDR=/usr/data/mysql/mysqld.sock \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_TCP_PORT=3306 \
-DEXTRA_CHARSETS=all \-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DMYSQL_UNIX_ADDR=/usr/data/mysql/mysql.sock \
-DMYSQL_USER=mysql \
-DWITH_DEBUG=0
------End Copy------
[root@localhost mysql-5.5.20]# make && make install
(7)复制配置文件:(/mnt/mysql-5.5.20)
[root@localhost mysql-5.5.20]# cp support-files/my-medium.cnf /etc/my.cnf
[root@localhost mysql-5.5.20]# cp support-files/mysql.server /etc/init.d/mysqld
[root@localhost mysql-5.5.20]# chmod 755 /etc/init.d/mysqld
------Start Copy------
cp support-files/my-medium.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
------End Copy------
(8)初始化数据库(/usr/local/mysql)
[root@localhost mysql-5.5.20]# bash /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/data/mysql/
------Start Copy------
bash /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/data/mysql/
------End Copy------
(9)启动mysql服务并查看
[root@localhost mysql-5.5.20]# /etc/init.d/mysqld start
[root@localhost mysql-5.5.20]# ps -ef |grep mysql
(10)通过命令行登录管理MySQL服务器,初始密码为空
[root@localhost mysql-5.5.20]# /usr/local/mysql/bin/mysql -u root -p
(11)修改root密码,并测试
mysql> use mysql;
mysql> update user set password=PASSWORD("qqqqqq") where user='root';
mysql> FLUSH PRIVILEGES;
------Start Copy------
use mysql;
update user set password=PASSWORD("qqqqqq") where user='root';
FLUSH PRIVILEGES;
exit
------End Copy------
再次启动MySQL服务器验证修改过的密码
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
(12)设置MySQL开机启动
[root@localhost mysql-5.5.20]# cd /etc
[root@localhost etc]# vim rc.local
---------
7 touch /var/lock/subsys/local
8 /usr/local/apache2/bin/apachectl start
9 /etc/init.d/mysqld start
---------
[root@localhost etc]# cat rc.local
(12)创建别名:alias mysql='/usr/local/mysql/bin/mysql -u root -p'
shell脚本自动安装:
【2018年2月28日 21:32:55】
启动(包括:yum -y remove http* mysql* php*,这种一键装方式)
[root@localhost ~]# /etc/init.d/mysqld start
修改密码后:
[root@localhost ~]# mysql -uroot -p
远程连接出现Error 1130问题
mysql>use mysql;
mysql>update user set host = '%' where user = 'root';
mysql>flush privileges;
mysql>select host, user from user
对于“ERROR 1062 (23000): Duplicate entry '%-root' for key 1”报错的解决方案
mysql> update user set host='%' where user = 'root';
ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'
然后查看了下数据库的host信息如下:
mysql> select host from user where user = 'root';
+-----------------------+
| host |
+-----------------------+
| % |
| 127.0.0.1 |
| localhost.localdomain |
+-----------------------+
3 rows in set (0.00 sec)
host已经有了%这个值,所以直接运行命令,即可用工具链接
mysql>flush privileges;
启动apache
[root@localhost ~]# service httpd start
Starting httpd: [ OK ]
【Sat Jun 17 2017 09:20:20 GMT+0800】
简要步骤:
1、VMware Workstation安装
(1)“文件”→“新建虚拟机(N)...”
(2)弹出“新建虚拟机安装向导”选“典型(推荐)(T)”,单击“下一步”
(3)安装客户机操作系统选择“稍后安装操作系统”
(4)选择客户机操作系统:
-客户机操作系统选择“Linux”;
-版本选择“CentOS”
(5)命名虚拟机
-虚拟机名称:CentOS
-位置:F:\sys\CentOS
(6)指定磁盘容量:
-最大磁盘大小(GB)(S):5.0(选择5GB)
-选择“将虚拟磁盘存储为单个文件”
(7)已准备好创建虚拟机
(8)编辑虚拟机设置:
-将内存改为“512M”或“256M”
-网络适配器定义为:“VMnet1”
-移除不需要的:“USB 控制器”、“声卡”、“打印机”
-在“CD/DVD (IDE)”的右侧面板的“连接”→“适用 ISO 镜像文件”,浏览找到“CentOS-5.5-i386-bin-DVD.iso”
(9)开启次虚拟机
2、CentOS5.5安装
移除分区、取消桌面、添加开发工具包
3、检测安装是否正确
(1)查看IP地址:ifconfig
(2)防火墙:iptables -L
(3)查看SELinux状态:sestauts
(4)检测开发工具包是否已安装:rpm -qa | grep gcc
图文步骤:
1、VMware Workstation安装
(1)“文件”→“新建虚拟机(N)...”
(2)弹出“新建虚拟机安装向导”选“典型(推荐)(T)”,单击“下一步”
(3)安装客户机操作系统选择“稍后安装操作系统”
(4)选择客户机操作系统:
-客户机操作系统选择“Linux”;
-版本选择“CentOS”
(5)命名虚拟机
-虚拟机名称:CentOS
-位置:F:\sys\CentOS
(6)指定磁盘容量:
-最大磁盘大小(GB)(S):5.0(选择5GB)
-选择“将虚拟磁盘存储为单个文件”
(7)已准备好创建虚拟机
(8)编辑虚拟机设置:
-将内存改为“512M”或“256M”
-网络适配器定义为:“VMnet1”
-移除不需要的:“USB 控制器”、“声卡”、“打印机”
-在“CD/DVD (IDE)”的右侧面板的“连接”→“适用 ISO 镜像文件”,浏览找到“CentOS-5.5-i386-bin-DVD.iso”
(9)开启次虚拟机
2、CentOS5.5安装
(1)进入下图界面,回车
选择skip回车
进入下图界面,点击“下一步”
选择“English(English)”,点击“下一步”
选择”U.S. English“,点击“下一步”
下图弹框选择”Yes“,
继续点击”Yes“,点击“下一步”
格式化磁盘,选择"Remove linux partitions on selected drives and create default layou"(在选择移除Linux分区驱动并且创建默认的布局),弹框移除分区,选择"Next"→“Yes”
配置IP
选择“OK”
点击“下一步”选择“继续”
输入密码(qqqqqq),点击“下一步”
把“Desktop - Gnome ”取消,并且选择"Customize now",点击“下一步”
在“Development”的右面选择“Development Tools”,点击“下一步”
点击“下一步”等待安装
点击“Rebot”重启,第一次重启进入下图界面
Run Tool 用tab选择,选择好后,回车,进入下图界面
按照上图选择好后,tab到"OK",回车,返回下图界面
tab到“Exit”回车,进入系统。
3、检测安装是否正确
(1)查看IP地址:ifconfig
(2)防火墙:iptables -L
(3)查看SELinux状态:sestauts
(4)检测开发工具包是否已安装:rpm -qa | grep gcc