1. 程式人生 > >centos7安裝JDK和MySQL

centos7安裝JDK和MySQL

[root@iZ2ze391v078jx2kq9s5r0Z ~]# yum list installed|grep java
[root@iZ2ze391v078jx2kq9s5r0Z ~]# yum -y list java*
Loaded plugins: security
Available Packages
java-1.8.0-openjdk.x86_64                                                 1:1.8.0.111-0.b15.el6_8                                      updates
java-1.8.0-openjdk-debug.x86_64                                           1:1.8.0.111-0.b15.el6_8                                      updates
javacc-manual.x86_64                                                      4.1-0.5.el6                                                  base   
javassist.noarch                                                          3.9.0-6.el6                                                  base   
javassist-javadoc.noarch                                                  3.9.0-6.el6                                                  base   
javastroke.x86_64                                                         0.5.1-33.el6                                                 epel   
javatar.noarch                                                            2.5-5.el6                                                    epel   
javatar-javadoc.noarch                                                    2.5-5.el6                                                    epel   
[root@iZ2ze391v078jx2kq9s5r0Z ~]# yum -y install java-1.8.0-openjdk*
Loaded plugins: security
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package java-1.8.0-openjdk.x86_64 1:1.8.0.111-0.b15.el6_8 will be installed
  java-1.8.0-openjdk-javadoc.noarch 1:1.8.0.111-0.b15.el6_8          java-1.8.0-openjdk-javadoc-debug.noarch 1:1.8.0.111-0.b15.el6_8         
  java-1.8.0-openjdk-src.x86_64 1:1.8.0.111-0.b15.el6_8              java-1.8.0-openjdk-src-debug.x86_64 1:1.8.0.111-0.b15.el6_8             

Dependency Installed:
  giflib.x86_64 0:4.1.6-3.1.el6                    jpackage-utils.noarch 0:1.7.5-3.16.el6            libXfont.x86_64 0:1.5.1-2.el6            
  libfontenc.x86_64 0:1.1.2-3.el6                  ttmkfdir.x86_64 0:3.0.9-32.1.el6                  tzdata-java.noarch 0:2016j-1.el6         
  xorg-x11-font-utils.x86_64 1:7.2-11.el6          xorg-x11-fonts-Type1.noarch 0:7.2-11.el6         

Dependency Updated:
  nspr.x86_64 0:4.11.0-1.el6                          nss.x86_64 0:3.21.3-2.el6_8               nss-softokn.x86_64 0:3.14.3-23.3.el6_8      
  nss-softokn-freebl.x86_64 0:3.14.3-23.3.el6_8       nss-sysinit.x86_64 0:3.21.3-2.el6_8       nss-tools.x86_64 0:3.21.3-2.el6_8           
  nss-util.x86_64 0:3.21.3-1.el6_8                   

Complete!
[root@iZ2ze391v078jx2kq9s5r0Z ~]# ping google.com
PING google.com (172.217.24.14) 56(84) bytes of data.

--- google.com ping statistics ---
27 packets transmitted, 0 received, 100% packet loss, time 26000ms

[root@iZ2ze391v078jx2kq9s5r0Z ~]# java -version
openjdk version "1.8.0_111"
OpenJDK Runtime Environment (build 1.8.0_111-b15)
OpenJDK 64-Bit Server VM (build 25.111-b15, mixed mode)

--- youtobe.com ping statistics ---
47 packets transmitted, 0 received, 100% packet loss, time 46276ms

[root@iZ2ze391v078jx2kq9s5r0Z ~]# ping youtobe.com
PING youtobe.com (54.208.99.166) 56(84) bytes of data.
--- youtobe.com ping statistics ---
2 packets transmitted, 0 received, 100% packet loss, time 1104ms

[root@iZ2ze391v078jx2kq9s5r0Z ~]# ping google.cn
PING google.cn (203.208.43.80) 56(84) bytes of data.
64 bytes from 203.208.43.80: icmp_seq=1 ttl=55 time=3.00 ms
64 bytes from 203.208.43.80: icmp_seq=2 ttl=55 time=3.00 ms

--- google.cn ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5303ms
rtt min/avg/max/mdev = 2.998/3.042/3.124/0.084 ms
[root@iZ2ze391v078jx2kq9s5r0Z ~]# yum -y list mysql*
Loaded plugins: security
Installed Packages
mysql-libs.x86_64                                                       5.1.73-3.el6_5                                                @updates
Available Packages
MySQL-python.x86_64                                                     1.2.3-0.3.c1.1.el6                                            base    
MySQL-zrm.noarch                                                        3.0-6.el6                                                     epel    
mysql.x86_64                                                            5.1.73-7.el6                                                  base    
mysql++.i686                                                            3.0.9-3.el6                                                   epel    
mysql++.x86_64                                                          3.0.9-3.el6                                                   epel    
mysql++-devel.i686                                                      3.0.9-3.el6                                                   epel    
mysql++-devel.x86_64                                                    3.0.9-3.el6                                                   epel    
mysql++-manuals.x86_64                                                  3.0.9-3.el6                                                   epel    
mysql-server.x86_64                                                     5.1.73-7.el6                                                  base    
mysql-test.x86_64                                                       5.1.73-7.el6                                                  base    
mysql-utilities.noarch                                                  1.3.6-1.el6                                                   epel    
mysqlreport.noarch                                                      3.5-4.el6                                                     epel    
mysqltuner.noarch                                                       1.6.0-1.el6                                                   epel    
[root@iZ2ze391v078jx2kq9s5r0Z ~]# rpm -qa|grep mysql*
mysql-libs-5.1.73-3.el6_5.x86_64
[root@iZ2ze391v078jx2kq9s5r0Z ~]# mysql -u root -p 123456
-bash: mysql: command not found
[root@iZ2ze391v078jx2kq9s5r0Z ~]# ls /etc/init.d/mysqld start
ls: cannot access /etc/init.d/mysqld: No such file or directory
ls: cannot access start: No such file or directory
[root@iZ2ze391v078jx2kq9s5r0Z ~]# /etc/init.d/mysqld start
-bash: /etc/init.d/mysqld: No such file or directory
[root@iZ2ze391v078jx2kq9s5r0Z ~]# ls -a /etc/
.                  crypttab                 gtk-2.0         lsb-release      pcmcia                        rc.local        statetab.d
..                 csh.cshrc                hal             lsb-release.d    pinforc                       rc.sysinit      subversion
abrt               csh.login                host.conf       lvm              pkcs11                        readahead.conf  sudo.conf
crontab            gshadow                  logrotate.conf  passwd           rc6.d                         ssl
cron.weekly        gshadow-                 logrotate.d     passwd-          rc.d                          statetab
[root@iZ2ze391v078jx2kq9s5r0Z ~]# rpm -e mysql-libs --nodeps
[root@iZ2ze391v078jx2kq9s5r0Z ~]# rpm -Uvh http://mirror.steadfast.net/epel/6/i386/epel-release-6-8.noarch.rpm
Retrieving http://mirror.steadfast.net/epel/6/i386/epel-release-6-8.noarch.rpm
warning: /var/tmp/rpm-tmp.6q024g: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing...                ########################################### [100%]
   1:epel-release           ########################################### [100%]
[root@iZ2ze391v078jx2kq9s5r0Z ~]# yum --enablerepo=remi,remi-test list mysql mysql-server
Loaded plugins: security
Repository epel is listed more than once in the configuration
Available Packages
mysql.x86_64                                                            5.1.73-7.el6                                                      base
mysql-server.x86_64                                                     5.1.73-7.el6                                                      base
[root@iZ2ze391v078jx2kq9s5r0Z ~]# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
Retrieving http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
warning: /var/tmp/rpm-tmp.3gGMnT: Header V4 DSA/SHA1 Signature, key ID 00f97f56: NOKEY
Preparing...                ########################################### [100%]
   1:remi-release           ########################################### [100%]
[root@iZ2ze391v078jx2kq9s5r0Z ~]# yum --enablerepo=remi,remi-test list mysql mysql-server
Loaded plugins: security
Repository epel is listed more than once in the configuration
remi                                                                                                                   | 2.9 kB     00:00     
remi/primary_db                                                                                                        | 1.7 MB     00:18     
remi-safe                                                                                                              | 2.9 kB     00:00     
remi-safe/primary_db                                                                                                   | 436 kB     00:17     
remi-test                                                                                                              | 2.9 kB     00:00     
remi-test/primary_db                                                                                                   | 358 kB     00:20     
Available Packages
mysql.x86_64                                                          5.5.54-1.el6.remi                                                   remi
mysql-server.x86_64                                                   5.5.54-1.el6.remi                                                   remi
[root@iZ2ze391v078jx2kq9s5r0Z ~]# yum --enablerepo=remi,remi-test install mysql mysql-server
Loaded plugins: security
Repository epel is listed more than once in the configuration
Setting up Install Process
Resolving Dependencies
--> Running transaction check
--> Running transaction check
---> Package compat-mysql51.x86_64 0:5.1.54-1.el6.remi will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================================
 Package                              Arch                         Version                                   Repository                  Size
==============================================================================================================================================
Installing:
 mysql                                x86_64                       5.5.54-1.el6.remi                         remi                       5.7 M
 mysql-server                         x86_64                       5.5.54-1.el6.remi                         remi                        10 M
Installing for dependencies:
 compat-mysql51                       x86_64                       5.1.54-1.el6.remi                         remi                       1.4 M
 mysql-libs                           x86_64                       5.5.54-1.el6.remi                         remi                       780 k
 perl-DBD-MySQL                       x86_64                       4.013-3.el6                               base                       134 k
 perl-DBI                             x86_64                       1.609-4.el6                               base                       705 k

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

Total download size: 19 M
Installed size: 84 M
Is this ok [y/N]: y
Downloading Packages:
(1/6): compat-mysql51-5.1.54-1.el6.remi.x86_64.rpm                                                                     | 1.4 MB     00:43     
(2/6): mysql-5.5.54-1.el6.remi.x86_64.rpm                                                                              | 5.7 MB     02:27     
(3/6): mysql-libs-5.5.54-1.el6.remi.x86_64.rpm                                                                         | 780 kB     00:21     
(4/6): mysql-server-5.5.54-1.el6.remi.x86_64.rpm                                                                       |  10 MB     03:57     
(5/6): perl-DBD-MySQL-4.013-3.el6.x86_64.rpm                                                                           | 134 kB     00:00     
(6/6): perl-DBI-1.609-4.el6.x86_64.rpm                                                                                 | 705 kB     00:00     
----------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                          43 kB/s |  19 MB     07:32     
warning: rpmts_HdrFromFdno: Header V4 DSA/SHA1 Signature, key ID 00f97f56: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
Importing GPG key 0x00F97F56:
 Userid : Remi Collet <[email protected]>
 Package: remi-release-6.8-1.el6.remi.noarch (installed)
 From   : /etc/pki/rpm-gpg/RPM-GPG-KEY-remi
Is this ok [y/N]: y
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-libs-5.5.54-1.el6.remi.x86_64                                                                                        1/6 

WARNING : This MySQL RPM is not an official Fedora / Red Hat build and it
overrides the official one. Don't file bugs on Fedora Project nor Red Hat.
Use dedicated forum at http://forum.remirepo.net/

  Installing : perl-DBI-1.609-4.el6.x86_64                                                                                                2/6 
  Installing : mysql-5.5.54-1.el6.remi.x86_64                                                                                             3/6 
  Installing : compat-mysql51-5.1.54-1.el6.remi.x86_64                                                                                    4/6 
  Installing : perl-DBD-MySQL-4.013-3.el6.x86_64                                                                                          5/6 
  Installing : mysql-server-5.5.54-1.el6.remi.x86_64                                                                                      6/6 
  Verifying  : mysql-5.5.54-1.el6.remi.x86_64                                                                                             1/6 
  Verifying  : compat-mysql51-5.1.54-1.el6.remi.x86_64                                                                                    2/6 
  Verifying  : perl-DBD-MySQL-4.013-3.el6.x86_64                                                                                          3/6 
  Verifying  : perl-DBI-1.609-4.el6.x86_64                                                                                                4/6 
  Verifying  : mysql-libs-5.5.54-1.el6.remi.x86_64                                                                                        5/6 
  Verifying  : mysql-server-5.5.54-1.el6.remi.x86_64                                                                                      6/6 

Installed:
  mysql.x86_64 0:5.5.54-1.el6.remi                                   mysql-server.x86_64 0:5.5.54-1.el6.remi                                  

Dependency Installed:
  compat-mysql51.x86_64 0:5.1.54-1.el6.remi         mysql-libs.x86_64 0:5.5.54-1.el6.remi         perl-DBD-MySQL.x86_64 0:4.013-3.el6        
  perl-DBI.x86_64 0:1.609-4.el6                    

Complete!
[root@iZ2ze391v078jx2kq9s5r0Z ~]# /etc/init.d/mysqld start
Initializing MySQL database:  WARNING: The host 'iZ2ze391v078jx2kq9s5r0Z' could not be looked up with resolveip.
This probably means that your libc libraries are not 100 % compatible
with this binary MySQL version. The MySQL daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MySQL privileges !
Installing MySQL system tables...
161213 16:27:27 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
161213 16:27:27 [Note] /usr/libexec/mysqld (mysqld 5.5.54) starting as process 1369 ...
OK
Filling help tables...
161213 16:27:28 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
161213 16:27:28 [Note] /usr/libexec/mysqld (mysqld 5.5.54) starting as process 1376 ...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h iZ2ze391v078jx2kq9s5r0Z password 'new-password'

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl

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

                                                           [  OK  ]
Starting mysqld:                                           [  OK  ]
[root@iZ2ze391v078jx2kq9s5r0Z ~]# chkconfig --levels 345 mysqld on
[root@iZ2ze391v078jx2kq9s5r0Z ~]# /usr/bin/mysql_secure_installation




NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!


In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n
 ... skipping.

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] n
 ... skipping.

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...



All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!


[root@iZ2ze391v078jx2kq9s5r0Z ~]# mysql -uroot -p10086
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.5.54 MySQL Community Server (GPL) by Remi

Copyright (c) 2000, 2016, 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> 
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '10086' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH   PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql>