本文介绍使用mysql rpm 包 来安装mysql应用;
由于服务器内核可能存在版本过低,导致缺少依赖包;
1、rpm bundel包下载到 /usr/local/src中:
[root@localhost src]# lsmysql-5.7.11-1.el6.x86_64.rpm-bundle.tar
2解压缩bundle包
[root@localhost src]# tar xf mysql-5.7.11-1.el6.x86_64.rpm-bundle.tar [root@localhost src]# lsmysql-5.7.11-1.el6.x86_64.rpm-bundle.tarmysql-community-client-5.7.11-1.el6.x86_64.rpmmysql-community-common-5.7.11-1.el6.x86_64.rpmmysql-community-devel-5.7.11-1.el6.x86_64.rpmmysql-community-embedded-5.7.11-1.el6.x86_64.rpmmysql-community-embedded-devel-5.7.11-1.el6.x86_64.rpmmysql-community-libs-5.7.11-1.el6.x86_64.rpmmysql-community-libs-compat-5.7.11-1.el6.x86_64.rpmmysql-community-server-5.7.11-1.el6.x86_64.rpmmysql-community-test-5.7.11-1.el6.x86_64.rpm
3.安装mysql-community-server之前,必须安装mysql-community-client和mysql-community-common rpm包。而安装community-client和community-common包之前,必须删除mysql-lib(系统自带的版本过低)
[root@localhost src]# rpm -qa | grep mysqlmysql-libs-5.1.73-3.el6_5.x86_64[root@localhost src]# yum remove mysql-libsLoaded plugins: fastestmirror, refresh-packagekit, securityExisting lock /var/run/yum.pid: another copy is running as pid 19475.Another app is currently holding the yum lock; waiting for it to exit... The other application is: PackageKit Memory : 39 M RSS (569 MB VSZ)Dependencies Resolved=========================================================================================== Package Arch version Repositor===================================================================================================================Removing: mysql-libs x86_64 5.1.73-3.el6_5 @anacondaRemoving for dependencies: cronie x86_64 1.4.4-12.el6 @anaconda cronie-anacron x86_64 1.4.4-12.el6 @anaconda crontabs noarch 1.10-33.el6 @anaconda postfix x86_64 2:2.6.6-6.el6_5 @anaconda sysstat x86_64 9.0.4-27.el6 @anacondaTransaction Summary===================================================================================================================Remove 6 Package(s)Installed size: 15 MIs this ok [y/N]: yDownloading Packages:Running rpm_check_debugRunning Transaction TestTransaction Test SucceededRunning Transaction Erasing : sysstat-9.0.4-27.el6.x86_64 Erasing : cronie-1.4.4-12.el6.x86_64 Erasing : cronie-anacron-1.4.4-12.el6.x86_64 Erasing : crontabs-1.10-33.el6.noarch Erasing : 2:postfix-2.6.6-6.el6_5.x86_64 Erasing : mysql-libs-5.1.73-3.el6_5.x86_64 Verifying : cronie-anacron-1.4.4-12.el6.x86_64 Verifying : mysql-libs-5.1.73-3.el6_5.x86_64 Verifying : sysstat-9.0.4-27.el6.x86_64 Verifying : crontabs-1.10-33.el6.noarch Verifying : cronie-1.4.4-12.el6.x86_64 Verifying : 2:postfix-2.6.6-6.el6_5.x86_64 Removed: mysql-libs.x86_64 0:5.1.73-3.el6_5 Dependency Removed: cronie.x86_64 0:1.4.4-12.el6 cronie-anacron.x86_64 0:1.4.4-12.el6 crontabs.noarch 0:1.10-33.el6 postfix.Complete!
4.上面卸载了mysql-lib旧的包,现在安装mysql-lib最新版的文件,这个包在rpm-bundle里面都有,
直接安装即可
[root@localhost src]# rpm -ivh mysql-community-common-5.7.11-1.el6.x86_64.rpm warning: mysql-community-common-5.7.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEYPreparing... ########################################### [100%] 1:mysql-community-common ########################################### [100%]
[root@localhost src]# lsmysql-5.7.11-1.el6.x86_64.rpm-bundle.tar mysql-community-embedded-5.7.11-1.el6.x86_64.rpm mysql-commumysql-community-client-5.7.11-1.el6.x86_64.rpm mysql-community-embedded-devel-5.7.11-1.el6.x86_64.rpm mysql-commumysql-community-common-5.7.11-1.el6.x86_64.rpm mysql-community-libs-5.7.11-1.el6.x86_64.rpmmysql-community-devel-5.7.11-1.el6.x86_64.rpm mysql-community-libs-compat-5.7.11-1.el6.x86_64.rpm[root@localhost src]# rpm -ivh mysql-community-libs-5.7.11-1.el6.x86_64.rpm warning: mysql-community-libs-5.7.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEYPreparing... ########################################### [100%] 1:mysql-community-libs ########################################### [100%][root@localhost src]# rpm -ivh mysql-community-client-5.7.11-1.el6.x86_64.rpm warning: mysql-community-client-5.7.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEYPreparing... ########################################### [100%] 1:mysql-community-client ########################################### [100%][root@localhost src]# rpm -ivh mysql-community-server-5.7.11-1.el6.x86_64.rpm warning: mysql-community-server-5.7.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEYPreparing... ########################################### [100%] 1:mysql-community-server ########################################### [100%]
5.启动mysql 服务
[root@localhost src]# service mysql startmysql: unrecognized service[root@localhost src]# service mysqld startInitializing MySQL database: [ OK ]Installing validate password plugin: [ OK ]Starting mysqld: [ OK ][root@localhost src]# netstat -tlunpActive Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1525/sshd tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1384/cupsd tcp 0 0 :::22 :::* LISTEN 1525/sshd tcp 0 0 ::1:631 :::* LISTEN 1384/cupsd tcp 0 0 :::3306 :::* LISTEN 19928/mysqld udp 0 0 0.0.0.0:68 0.0.0.0:* 19346/dhclient udp 0 0 0.0.0.0:631 0.0.0.0:* 1384/cupsd
6.rpm安装mysql后,会自动初始化一个密码,在日志中
[root@localhost src]# cat /var/log/mysqld.log | more2016-03-11T01:44:19.913630Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).2016-03-11T01:44:22.271099Z 0 [Warning] InnoDB: New log files created, LSN=457902016-03-11T01:44:22.584299Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.2016-03-11T01:44:23.050146Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: c7bf1a6a-e72a-11e5-8737-000c29a05942.2016-03-11T01:44:23.062259Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++2016-03-11T01:44:23.093873Z 1 [Note] A temporary password is generated for root@localhost: 8%
7.修改 mysql root密码,由于最新的mysql版本对密码策略有要求,所以必须增加复杂程度才能通过
注意,用刚才的随机密码登陆mysql.
[root@localhost src]# mysql -uroot -pEnter password: 此处输入刚才日志文件中的随机密码Welcome to the MySQL monitor. commands end with ; or \g.Your MySQL connection id is 14Server version: 5.7.11Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> set password='Yes@126.com';Query OK, 0 rows affected (0.15 sec)mysql> quit;Bye[root@localhost src]# mysql -uroot -pEnter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 15Server version: 5.7.11 MySQL Community Server (GPL)Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
默认情况下,mysql只允许locathost本地登陆,用mysql workbentch 是无法远程登陆的。
root@localhost,代表root只允许本地用户登陆,
所以必须允许root 从任何登陆。
mysql> grant all privileges on *.* to 'root'@'%' identified by 'Yes@126.com';
###############################################################################
###############################################################################
实操记录:[root@localhost tmp]# cd /usr/local/src[root@localhost src]# lltotal 429204-rwxrw-rw-. 1 wdl wdl 439500800 Apr 6 20:05 mysql-5.7.11-1.el6.x86_64.rpm-bundle.tar[root@localhost src]# tar xf mysql-5.7.11-1.el6.x86_64.rpm-bundle.tar[root@localhost src]# lltotal 858408-rwxrw-rw-. 1 wdl wdl 439500800 Apr 6 20:05 mysql-5.7.11-1.el6.x86_64.rpm-bundle.tar-rw-r--r--. 1 7155 wheel 24176228 Feb 2 01:31 mysql-community-client-5.7.11-1.el6.x86_64.rpm-rw-r--r--. 1 7155 wheel 333480 Feb 2 01:31 mysql-community-common-5.7.11-1.el6.x86_64.rpm-rw-r--r--. 1 7155 wheel 3854020 Feb 2 01:31 mysql-community-devel-5.7.11-1.el6.x86_64.rpm-rw-r--r--. 1 7155 wheel 38247128 Feb 2 01:31 mysql-community-embedded-5.7.11-1.el6.x86_64.rpm-rw-r--r--. 1 7155 wheel 130605584 Feb 2 01:32 mysql-community-embedded-devel-5.7.11-1.el6.x86_64.rpm-rw-r--r--. 1 7155 wheel 2237704 Feb 2 01:32 mysql-community-libs-5.7.11-1.el6.x86_64.rpm-rw-r--r--. 1 7155 wheel 1722544 Feb 2 01:32 mysql-community-libs-compat-5.7.11-1.el6.x86_64.rpm-rw-r--r--. 1 7155 wheel 141256272 Feb 2 01:33 mysql-community-server-5.7.11-1.el6.x86_64.rpm-rw-r--r--. 1 7155 wheel 97051252 Feb 2 01:34 mysql-community-test-5.7.11-1.el6.x86_64.rpm[root@localhost src]# rpm -qa | grep mysqlmysql-libs-5.1.71-1.el6.x86_64[root@localhost src]# [root@localhost src]# [root@localhost src]# yum remove mysql-libsLoaded plugins: product-id, refresh-packagekit, security, subscription-managerThis system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.Setting up Remove ProcessResolving Dependencies--> Running transaction check---> Package mysql-libs.x86_64 0:5.1.71-1.el6 will be erased--> Processing Dependency: libmysqlclient.so.16()(64bit) for package: 2:postfix-2.6.6-2.2.el6_1.x86_64--> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16)(64bit) for package: 2:postfix-2.6.6-2.2.el6_1.x86_64--> Processing Dependency: mysql-libs for package: 2:postfix-2.6.6-2.2.el6_1.x86_64--> Running transaction check---> Package postfix.x86_64 2:2.6.6-2.2.el6_1 will be erased--> Processing Dependency: /usr/sbin/sendmail for package: cronie-1.4.4-12.el6.x86_64--> Running transaction check---> Package cronie.x86_64 0:1.4.4-12.el6 will be erased--> Processing Dependency: cronie = 1.4.4-12.el6 for package: cronie-anacron-1.4.4-12.el6.x86_64--> Running transaction check---> Package cronie-anacron.x86_64 0:1.4.4-12.el6 will be erased--> Processing Dependency: /etc/cron.d for package: crontabs-1.10-33.el6.noarch--> Processing Dependency: /etc/cron.d for package: sysstat-9.0.4-22.el6.x86_64--> Restarting Dependency Resolution with new changes.--> Running transaction check---> Package crontabs.noarch 0:1.10-33.el6 will be erased---> Package sysstat.x86_64 0:9.0.4-22.el6 will be erased--> Finished Dependency ResolutionDependencies Resolved============================================================================================================================================================= Package Arch Version Repository Size=============================================================================================================================================================Removing: mysql-libs x86_64 5.1.71-1.el6 @anaconda-RedHatEnterpriseLinux-201311111358.x86_64/6.5 4.0 MRemoving for dependencies: cronie x86_64 1.4.4-12.el6 @anaconda-RedHatEnterpriseLinux-201311111358.x86_64/6.5 174 k cronie-anacron x86_64 1.4.4-12.el6 @anaconda-RedHatEnterpriseLinux-201311111358.x86_64/6.5 43 k crontabs noarch 1.10-33.el6 @anaconda-RedHatEnterpriseLinux-201311111358.x86_64/6.5 2.4 k postfix x86_64 2:2.6.6-2.2.el6_1 @anaconda-RedHatEnterpriseLinux-201311111358.x86_64/6.5 9.7 M sysstat x86_64 9.0.4-22.el6 @anaconda-RedHatEnterpriseLinux-201311111358.x86_64/6.5 824 kTransaction Summary=============================================================================================================================================================Remove 6 Package(s)Installed size: 15 MIs this ok [y/N]: yDownloading Packages:Running rpm_check_debugRunning Transaction TestTransaction Test SucceededRunning Transaction Erasing : sysstat-9.0.4-22.el6.x86_64 1/6 Erasing : cronie-1.4.4-12.el6.x86_64 2/6 Erasing : cronie-anacron-1.4.4-12.el6.x86_64 3/6 Erasing : crontabs-1.10-33.el6.noarch 4/6 Erasing : 2:postfix-2.6.6-2.2.el6_1.x86_64 5/6 Erasing : mysql-libs-5.1.71-1.el6.x86_64 6/6 Verifying : cronie-anacron-1.4.4-12.el6.x86_64 1/6 Verifying : 2:postfix-2.6.6-2.2.el6_1.x86_64 2/6 Verifying : mysql-libs-5.1.71-1.el6.x86_64 3/6 Verifying : crontabs-1.10-33.el6.noarch 4/6 Verifying : sysstat-9.0.4-22.el6.x86_64 5/6 Verifying : cronie-1.4.4-12.el6.x86_64 6/6 Removed: mysql-libs.x86_64 0:5.1.71-1.el6 Dependency Removed: cronie.x86_64 0:1.4.4-12.el6 cronie-anacron.x86_64 0:1.4.4-12.el6 crontabs.noarch 0:1.10-33.el6 postfix.x86_64 2:2.6.6-2.2.el6_1 sysstat.x86_64 0:9.0.4-22.el6 Complete![root@localhost src]# lltotal 858408-rwxrw-rw-. 1 wdl wdl 439500800 Apr 6 20:05 mysql-5.7.11-1.el6.x86_64.rpm-bundle.tar-rw-r--r--. 1 7155 wheel 24176228 Feb 2 01:31 mysql-community-client-5.7.11-1.el6.x86_64.rpm-rw-r--r--. 1 7155 wheel 333480 Feb 2 01:31 mysql-community-common-5.7.11-1.el6.x86_64.rpm-rw-r--r--. 1 7155 wheel 3854020 Feb 2 01:31 mysql-community-devel-5.7.11-1.el6.x86_64.rpm-rw-r--r--. 1 7155 wheel 38247128 Feb 2 01:31 mysql-community-embedded-5.7.11-1.el6.x86_64.rpm-rw-r--r--. 1 7155 wheel 130605584 Feb 2 01:32 mysql-community-embedded-devel-5.7.11-1.el6.x86_64.rpm-rw-r--r--. 1 7155 wheel 2237704 Feb 2 01:32 mysql-community-libs-5.7.11-1.el6.x86_64.rpm-rw-r--r--. 1 7155 wheel 1722544 Feb 2 01:32 mysql-community-libs-compat-5.7.11-1.el6.x86_64.rpm-rw-r--r--. 1 7155 wheel 141256272 Feb 2 01:33 mysql-community-server-5.7.11-1.el6.x86_64.rpm-rw-r--r--. 1 7155 wheel 97051252 Feb 2 01:34 mysql-community-test-5.7.11-1.el6.x86_64.rpm[root@localhost src]# rpm -ivh mysql-community-common-5.7.11-1.el6.x86_64.rpmwarning: mysql-community-common-5.7.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEYPreparing... ########################################### [100%] 1:mysql-community-common ########################################### [100%][root@localhost src]# [root@localhost src]# rpm -ivh mysql-community-libs-5.7.11-1.el6.x86_64.rpm warning: mysql-community-libs-5.7.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEYPreparing... ########################################### [100%] 1:mysql-community-libs ########################################### [100%][root@localhost src]# rpm -ivh mysql-community-client-5.7.11-1.el6.x86_64.rpmwarning: mysql-community-client-5.7.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEYPreparing... ########################################### [100%] 1:mysql-community-client ########################################### [100%][root@localhost src]# [root@localhost src]# rpm -ivh mysql-community-server-5.7.11-1.el6.x86_64.rpm warning: mysql-community-server-5.7.11-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEYPreparing... ########################################### [100%] 1:mysql-community-server ########################################### [100%][root@localhost src]# [root@localhost src]# [root@localhost src]# service mysql startmysql: unrecognized service[root@localhost src]# service mysqld startInitializing MySQL database: [ OK ]Installing validate password plugin: [ OK ]Starting mysqld: [ OK ][root@localhost src]# [root@localhost src]# [root@localhost src]# netstat -tlunpActive Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1826/sshd tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1716/cupsd tcp 0 0 :::22 :::* LISTEN 1826/sshd tcp 0 0 ::1:631 :::* LISTEN 1716/cupsd tcp 0 0 :::3306 :::* LISTEN 3451/mysqld udp 0 0 0.0.0.0:631 0.0.0.0:* 1716/cupsd [root@localhost src]# [root@localhost src]# [root@localhost src]# cat /var/log/mysqld.log | more2016-04-07T03:13:03.129452Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).2016-04-07T03:13:03.709996Z 0 [Warning] InnoDB: New log files created, LSN=457902016-04-07T03:13:03.924838Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.2016-04-07T03:13:04.048200Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: a4763859-fc6e-11e5-a4fc-510e5376564d.2016-04-07T03:13:04.052031Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.2016-04-07T03:13:04.057163Z 1 [Note] A temporary password is generated for root@localhost: IKIw)u*qX5A82016-04-07T03:13:08.935473Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).2016-04-07T03:13:08.937404Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.11) starting as process 3190 ...2016-04-07T03:13:08.964847Z 0 [Note] InnoDB: PUNCH HOLE support available2016-04-07T03:13:08.964908Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins2016-04-07T03:13:08.964920Z 0 [Note] InnoDB: Uses event mutexes2016-04-07T03:13:08.964931Z 0 [Note] InnoDB: GCC builtin __sync_synchronize() is used for memory barrier2016-04-07T03:13:08.964940Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.32016-04-07T03:13:08.964950Z 0 [Note] InnoDB: Using Linux native AIO2016-04-07T03:13:08.965500Z 0 [Note] InnoDB: Number of pools: 12016-04-07T03:13:08.965736Z 0 [Note] InnoDB: Not using CPU crc32 instructions2016-04-07T03:13:08.989066Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M2016-04-07T03:13:09.018058Z 0 [Note] InnoDB: Completed initialization of buffer pool2016-04-07T03:13:09.023580Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().2016-04-07T03:13:09.039564Z 0 [Note] InnoDB: Highest supported file format is Barracuda.2016-04-07T03:13:09.105655Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables2016-04-07T03:13:09.105983Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...2016-04-07T03:13:09.147257Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.2016-04-07T03:13:09.149058Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.2016-04-07T03:13:09.149157Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.2016-04-07T03:13:09.150437Z 0 [Note] InnoDB: Waiting for purge to start2016-04-07T03:13:09.201463Z 0 [Note] InnoDB: 5.7.11 started; log sequence number 24925542016-04-07T03:13:09.202888Z 0 [Note] Plugin 'FEDERATED' is disabled.2016-04-07T03:13:09.205368Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool2016-04-07T03:13:09.209724Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key2016-04-07T03:13:09.210064Z 0 [Note] Server hostname (bind-address): '*'; port: 33062016-04-07T03:13:09.210771Z 0 [Note] IPv6 is available.2016-04-07T03:13:09.210811Z 0 [Note] - '::' resolves to '::';[root@localhost src]# mysql -uroot -pEnter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 3Server version: 5.7.11Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> mysql> [root@localhost src]#