Linux升级Python步骤

首先在官网下载要更新安装的Python包,下载地址https://www.python.org/downloads
Python下载完成后上传到服务器,然后解压进行编译安装:
[root@monitor ~]# pwd
/root
[root@monitor ~]# tar -xzvf Python-2.7.10.tgz
[root@monitor ~]# cd Python-2.7.10
[root@monitor Python-2.7.10]# pwd
/root/Python-2.7.10
解压后可以查看README帮助文档进行安装,默认安装在/usr/local目录下:
[root@monitor Python-2.7.10]# ./configure
[root@monitor Python-2.7.10]# make
[root@monitor Python-2.7.10]# make install
[root@monitor Python-2.7.10]# cd /usr/local/bin/
[root@mysql ~]# cd /usr/local/bin/
[root@mysql bin]# ls -l
total 6116
-rwxr-xr-x. 1 root root     101 Aug 14 09:56 2to3
-rwxr-xr-x. 1 root root      99 Aug 14 09:56 idle
-rwxr-xr-x. 1 root root      84 Aug 14 09:56 pydoc
lrwxrwxrwx. 1 root root       7 Aug 14 09:59 python -> python2
lrwxrwxrwx. 1 root root       9 Aug 14 09:59 python2 -> python2.7
-rwxr-xr-x. 1 root root 6225046 Aug 14 09:58 python2.7
-rwxr-xr-x. 1 root root    1687 Aug 14 09:59 python2.7-config
lrwxrwxrwx. 1 root root      16 Aug 14 09:59 python2-config -> python2.7-config
lrwxrwxrwx. 1 root root      14 Aug 14 09:59 python-config -> python2-config
-rwxr-xr-x. 1 root root   18547 Aug 14 09:56 smtpd.py
此时没有覆盖老版本:
[root@mysql ~]# python
Python 2.6.6 (r266:84292, Nov 21 2013, 10:50:32)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
[root@mysql ~]# which python
/usr/local/bin/python
[root@mysql ~]# whereis python
python: /usr/bin/python2.6 /usr/bin/python /usr/lib/python2.6 /usr/lib64/python2.6 /usr/local/bin/python2.7-config /usr/local/bin/python2.7 /usr/local/bin/python /usr/local/lib/python2.7 /usr/include/python2.6 /usr/share/man/man1/python.1.gz 
将原来/usr/bin/python链接重命名:
[root@mysql ~]# mv /usr/bin/python /usr/bin/python_old
再建立新版本Python的链接
ln -s /usr/local/bin/python2.7  /usr/bin/python
这个时候输入python就会显示出python的新版本信息:
[root@mysql bin]# python
Python 2.7.10 (default, Aug 14 2016, 09:56:11)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
注意从Python3版本开始,默认安装可能会覆盖Linux下自带的老版本Python,也有可能不覆盖,具体看安装过程。

Linux安装启动MySQL 5.6

本篇是在《Linux卸载原生MySQL数据库》的基础之上进行安装,关于安装过程请参考http://www.cnblogs.com/zhuque/archive/2012/11/03/2763353.html

1.环境描述
MySQL版本5.6
OS版本RHEL 6.6

2.安装MySQL前准备
2.1.检查该环境中是否已安装MySQL
1)检查方法:netstat –ano命令查看MySQL默认端口3306是否存在
2)在命令行中执行mysql
3)使用rpm -qa|grep -i mysql查看
2.2.在Oracle Software Delivery Cloud下载MySQL 5.6安装包
安装包V75295-01.zip包含以下rpm包:
MySQL-client-advanced-5.6.24-1.el6.x86_64.rpm
MySQL-devel-advanced-5.6.24-1.el6.x86_64.rpm
MySQL-embedded-advanced-5.6.24-1.el6.x86_64.rpm
MySQL-server-advanced-5.6.24-1.el6.x86_64.rpm
MySQL-shared-advanced-5.6.24-1.el6.x86_64.rpm
MySQL-shared-compat-advanced-5.6.24-1.el6.x86_64.rpm
MySQL-test-advanced-5.6.24-1.el6.x86_64.rpm

3.执行安装
通常情况下MySQL安装只需安装MySQL-server和MySQL-client这两个组件包:
[root@dbtest5 MySQL]# pwd
/root/MySQL
[root@dbtest5 MySQL]# yum install MySQL-server-advanced-5.6.24-1.el6.x86_64.rpm
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Setting up Install Process
Examining MySQL-server-advanced-5.6.24-1.el6.x86_64.rpm: MySQL-server-advanced-5.6.24-1.el6.x86_64
Marking MySQL-server-advanced-5.6.24-1.el6.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package MySQL-server-advanced.x86_64 0:5.6.24-1.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================================================================================
 Package                                 Arch                     Version                        Repository                                                    Size
====================================================================================================================================================================
Installing:
 MySQL-server-advanced                   x86_64                   5.6.24-1.el6                   /MySQL-server-advanced-5.6.24-1.el6.x86_64                   258 M

Transaction Summary
====================================================================================================================================================================
Install       1 Package(s)

Total size: 258 M
Installed size: 258 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
** Found 3 pre-existing rpmdb problem(s), 'yum check' output follows:
2:postfix-2.6.6-6.el6_5.x86_64 has missing requires of libmysqlclient.so.16()(64bit)
2:postfix-2.6.6-6.el6_5.x86_64 has missing requires of libmysqlclient.so.16(libmysqlclient_16)(64bit)
2:postfix-2.6.6-6.el6_5.x86_64 has missing requires of mysql-libs
  Installing : MySQL-server-advanced-5.6.24-1.el6.x86_64                                                                                                        1/1 
2016-08-12 12:16:53 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-08-12 12:16:53 0 [Note] /usr/sbin/mysqld (mysqld 5.6.24-enterprise-commercial-advanced) starting as process 5400 ...
2016-08-12 12:16:53 5400 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-08-12 12:16:53 5400 [Note] InnoDB: The InnoDB memory heap is disabled
2016-08-12 12:16:53 5400 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-08-12 12:16:53 5400 [Note] InnoDB: Memory barrier is not used
2016-08-12 12:16:53 5400 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-08-12 12:16:53 5400 [Note] InnoDB: Using Linux native AIO
2016-08-12 12:16:53 5400 [Note] InnoDB: Using CPU crc32 instructions
2016-08-12 12:16:53 5400 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-08-12 12:16:53 5400 [Note] InnoDB: Completed initialization of buffer pool
2016-08-12 12:16:53 5400 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2016-08-12 12:16:53 5400 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2016-08-12 12:16:53 5400 [Note] InnoDB: Database physically writes the file full: wait...
2016-08-12 12:16:53 5400 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2016-08-12 12:16:54 5400 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2016-08-12 12:16:54 5400 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2016-08-12 12:16:54 5400 [Warning] InnoDB: New log files created, LSN=45781
2016-08-12 12:16:54 5400 [Note] InnoDB: Doublewrite buffer not found: creating new
2016-08-12 12:16:54 5400 [Note] InnoDB: Doublewrite buffer created
2016-08-12 12:16:54 5400 [Note] InnoDB: 128 rollback segment(s) are active.
2016-08-12 12:16:54 5400 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-08-12 12:16:54 5400 [Note] InnoDB: Foreign key constraint system tables created
2016-08-12 12:16:54 5400 [Note] InnoDB: Creating tablespace and datafile system tables.
2016-08-12 12:16:54 5400 [Note] InnoDB: Tablespace and datafile system tables created.
2016-08-12 12:16:54 5400 [Note] InnoDB: Waiting for purge to start
2016-08-12 12:16:54 5400 [Note] InnoDB: 5.6.24 started; log sequence number 0
2016-08-12 12:16:54 5400 [Note] RSA private key file not found: /var/lib/mysql//private_key.pem. Some authentication plugins will not work.
2016-08-12 12:16:54 5400 [Note] RSA public key file not found: /var/lib/mysql//public_key.pem. Some authentication plugins will not work.
2016-08-12 12:16:54 5400 [Note] Binlog end
2016-08-12 12:16:54 5400 [Note] InnoDB: FTS optimize thread exiting.
2016-08-12 12:16:54 5400 [Note] InnoDB: Starting shutdown...
2016-08-12 12:16:56 5400 [Note] InnoDB: Shutdown completed; log sequence number 1625977
A random root password has been set. You will find it in '/root/.mysql_secret'.


2016-08-12 12:16:56 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-08-12 12:16:56 0 [Note] /usr/sbin/mysqld (mysqld 5.6.24-enterprise-commercial-advanced) starting as process 5423 ...
2016-08-12 12:16:56 5423 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-08-12 12:16:56 5423 [Note] InnoDB: The InnoDB memory heap is disabled
2016-08-12 12:16:56 5423 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-08-12 12:16:56 5423 [Note] InnoDB: Memory barrier is not used
2016-08-12 12:16:56 5423 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-08-12 12:16:56 5423 [Note] InnoDB: Using Linux native AIO
2016-08-12 12:16:56 5423 [Note] InnoDB: Using CPU crc32 instructions
2016-08-12 12:16:56 5423 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-08-12 12:16:56 5423 [Note] InnoDB: Completed initialization of buffer pool
2016-08-12 12:16:56 5423 [Note] InnoDB: Highest supported file format is Barracuda.
2016-08-12 12:16:56 5423 [Note] InnoDB: 128 rollback segment(s) are active.
2016-08-12 12:16:56 5423 [Note] InnoDB: Waiting for purge to start
2016-08-12 12:16:56 5423 [Note] InnoDB: 5.6.24 started; log sequence number 1625977
2016-08-12 12:16:56 5423 [Note] RSA private key file not found: /var/lib/mysql//private_key.pem. Some authentication plugins will not work.
2016-08-12 12:16:56 5423 [Note] RSA public key file not found: /var/lib/mysql//public_key.pem. Some authentication plugins will not work.
2016-08-12 12:16:56 5423 [Note] Binlog end
2016-08-12 12:16:56 5423 [Note] InnoDB: FTS optimize thread exiting.
2016-08-12 12:16:56 5423 [Note] InnoDB: Starting shutdown...
2016-08-12 12:16:58 5423 [Note] InnoDB: Shutdown completed; log sequence number 1625987




A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
You will find that password in '/root/.mysql_secret'.

You must change that password on your first connect,
no other statement but 'SET PASSWORD' will be accepted.
See the manual for the semantics of the 'password expired' flag.

Also, the account for the anonymous user has been removed.

In addition, you can run:

  /usr/bin/mysql_secure_installation

which will also give you the option of removing the test database.
This is strongly recommended for production servers.

See the manual for more instructions.

Please report any problems at http://bugs.mysql.com/

The latest information about MySQL is available on the web at

http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

New default config file was created as /usr/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings

  Verifying  : MySQL-server-advanced-5.6.24-1.el6.x86_64                                                                                                        1/1 

Installed:
  MySQL-server-advanced.x86_64 0:5.6.24-1.el6                                                                                                                       

Complete!

[root@dbtest5 MySQL]# yum install MySQL-client-advanced-5.6.24-1.el6.x86_64.rpm
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Setting up Install Process
Examining MySQL-client-advanced-5.6.24-1.el6.x86_64.rpm: MySQL-client-advanced-5.6.24-1.el6.x86_64
Marking MySQL-client-advanced-5.6.24-1.el6.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package MySQL-client-advanced.x86_64 0:5.6.24-1.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================================================================================
 Package                                 Arch                     Version                        Repository                                                    Size
====================================================================================================================================================================
Installing:
 MySQL-client-advanced                   x86_64                   5.6.24-1.el6                   /MySQL-client-advanced-5.6.24-1.el6.x86_64                    72 M

Transaction Summary
====================================================================================================================================================================
Install       1 Package(s)

Total size: 72 M
Installed size: 72 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : MySQL-client-advanced-5.6.24-1.el6.x86_64                                                                                                        1/1 
  Verifying  : MySQL-client-advanced-5.6.24-1.el6.x86_64                                                                                                        1/1 

Installed:
  MySQL-client-advanced.x86_64 0:5.6.24-1.el6                                                                                                                       

Complete!

4.检查一下MySQL安装文件及位置
[root@dbtest5 ~]# which mysql      
/usr/bin/mysql
[root@dbtest5 ~]# whereis mysql          
mysql: /usr/bin/mysql /usr/lib64/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz
[root@dbtest5 ~]# find / -name mysql  
/usr/share/mysql
/usr/bin/mysql
/usr/lib64/mysql
/var/lib/mysql
/var/lib/mysql/mysql
/etc/rc.d/init.d/mysql
/etc/logrotate.d/mysql
1)数据库目录 /var/lib/mysql/
2)配置文件 /usr/share/mysql(mysql.server命令及配置文件)
3)相关命令 /usr/bin (mysqladmin mysqldump mysql等命令)
4)启动脚本 /etc/rc.d/init.d/(启动脚本文件mysql的目录)

5.启动MySQL
[root@dbtest5 ~]# service mysql status
MySQL is not running                                       [FAILED]
[root@dbtest5 ~]# service mysql start
Starting MySQL..                                           [  OK  ]
[root@dbtest5 ~]# service mysql status
MySQL running (5966)                                       [  OK  ]
注意:启动mysql服务也可以使用脚本/etc/init.d/mysql或/usr/share/mysql/mysql.server配置文件来执行,并且MySQL在5.5版本之后服务名从原来的mysqld改为mysql
[root@dbtest5 ~]# /etc/init.d/mysql status
MySQL running (5966)                                       [  OK  ]
[root@dbtest5 ~]# /etc/init.d/mysql stop
Shutting down MySQL..                                      [  OK  ]
[root@dbtest5 ~]# /etc/init.d/mysql start
Starting MySQL.                                            [  OK  ]
[root@dbtest5 ~]# /etc/init.d/mysql status
MySQL running (6393)                                       [  OK  ]
[root@dbtest5 ~]# /usr/share/mysql/mysql.server status
MySQL running (6393)                                       [  OK  ]
[root@dbtest5 ~]# /usr/share/mysql/mysql.server stop
Shutting down MySQL..                                      [  OK  ]
[root@dbtest5 ~]# /usr/share/mysql/mysql.server start
Starting MySQL.                                            [  OK  ]
[root@dbtest5 ~]# /usr/share/mysql/mysql.server status
MySQL running (6601)                                       [  OK  ]

6.配置MySQL自启动
[root@dbtest5 ~]# chkconfig --list|grep mysql
[root@dbtest5 ~]# chkconfig --add mysql
[root@dbtest5 ~]# chkconfig --list|grep mysql
mysql           0:off   1:off   2:off   3:off   4:off   5:off   6:off
[root@dbtest5 ~]# chkconfig --list|grep mysql
mysql           0:off   1:off   2:on    3:on    4:on    5:on    6:off

7.登陆MySQL
在MySQL 5.5之前版本,安装完成后初始化启动登陆MySQL数据库时,默认不需要使用密码即可登录:
[root@dbtest6 ~]# mysql -V
mysql  Ver 14.14 Distrib 5.1.73, for redhat-linux-gnu (x86_64) using readline 5.1
[root@dbtest6 ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
+--------------------+
3 rows in set (0.00 sec)

而从MySQL版本从5.5开始,初始化启动登陆MySQL时必须使用密码,否则报下面的错误:
[root@dbtest5 ~]# mysql -V
mysql  Ver 14.14 Distrib 5.6.24, for Linux (x86_64) using  EditLine wrapper
[root@dbtest5 ~]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
这是从安全角度考虑,MySQL在5.5.版本之后安装启动初始化的时候设置了一个随机密码,首次登陆后需要修改,从这段文字提示也可以看出:
A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
You will find that password in '/root/.mysql_secret'.

You must change that password on your first connect,
no other statement but 'SET PASSWORD' will be accepted.
See the manual for the semantics of the 'password expired' flag.
因此在MySQL安装初始化启动后,首次登陆时需要使用/root/.mysql_secret里随机生成的密码,登陆成功后再进行修改:
[root@dbtest5 ~]# cat /root/.mysql_secret
# The random password set for the root user at Fri Aug 12 12:16:54 2016 (local time): 1mekXLAbvT20XsvI
[root@dbtest5 ~]# mysql -uroot -p1mekXLAbvT20XsvI
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.6.24-enterprise-commercial-advanced

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
这里提示必须先修改密码:
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('oracle'); 
Query OK, 0 rows affected (0.00 sec)
初始密码修改成功:
[root@dbtest5 ~]# mysql -uroot -poracle
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.6.24-enterprise-commercial-advanced MySQL Enterprise Server - Advanced Edition (Commercial)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)

8.登陆MySQL报错解决办法
Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’
在登陆MySQL时如果报这个错误,首先检查下MySQL是否启动,其次/var/lib/mysql文件权限是否正确/var/lib/mysql
检查MySQL是否启动:service mysql status
修改MySQL文件权限;chown -R mysql:mysql /var/lib/mysql