1.先查找看是否安装mysql
[[email protected]]# rpm -qa | grep mysql
mysql-libs-5.1.71-1.el6.x86_64
明显有个开源的mysql库,先卸载
[[email protected]]# rpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64
2.在线查找 可安装的myql
[[email protected]]# yum searchmysql 在线查找 可安装的myql
Loaded plugins:fastestmirror
Loading mirrorspeeds from cached hostfile
* base: ftp.sjtu.edu.cn
* extras: mirror.bit.edu.cn
* updates: centos.ustc.edu.cn
base | 3.7 kB 00:00
extras | 3.4 kB 00:00
updates | 3.4 kB 00:00
=========================================N/S Matched: mysql ==========================================
MySQL-python.x86_64: An interface to MySQL
apr-util-mysql.x86_64: APR utility library MySQL DBD driver
bacula-director-mysql.x86_64: Bacula Director with MySQL database support
bacula-storage-mysql.x86_64: MySQL Bacula storage daemon files
dovecot-mysql.x86_64: MySQL back end for dovecot
freeradius-mysql.x86_64: MySQL support for freeradius
libdbi-dbd-mysql.x86_64: MySQL plugin for libdbi
mod_auth_mysql.x86_64: Basic authentication for the Apache web server using a MySQL database
mysql.x86_64 : MySQLclient programs and shared libraries
mysql-bench.x86_64 :MySQL benchmark scripts and data
mysql-connector-java.noarch: Official JDBC driver for MySQL
mysql-connector-odbc.x86_64: ODBC driver for MySQL
mysql-devel.i686 :Files for development of MySQL applications
mysql-devel.x86_64 :Files for development of MySQL applications
mysql-embedded.i686: MySQL as an embeddable library
mysql-embedded.x86_64: MySQL as an embeddable library
mysql-embedded-devel.i686: Development files for MySQL as an embeddable library
mysql-embedded-devel.x86_64: Development files for MySQL as an embeddable library
mysql-libs.i686 :The shared libraries required for MySQL clients
mysql-libs.x86_64 :The shared libraries required for MySQL clients
mysql-server.x86_64 : The MySQLserver and related files
mysql-test.x86_64 :The test suite distributed with MySQL
perl-DBD-MySQL.x86_64: A MySQL interface for perl
php-mysql.x86_64 : Amodule for PHP applications that use MySQL databases
qt-mysql.i686 :MySQL driver for Qt's SQL classes
qt-mysql.x86_64 :MySQL driver for Qt's SQL classes
qt3-MySQL.i686 :MySQL drivers for Qt 3's SQL classes
qt3-MySQL.x86_64 :MySQL drivers for Qt 3's SQL classes
rsyslog-mysql.x86_64: MySQL support for rsyslog
rsyslog7-mysql.x86_64: MySQL support for rsyslog
3.在线使用yum安装Mysql 服务器
[[email protected]]# yum -yinstall mysql-server.x86_64
下面的是在线安装的过程不用管,直到出到 Complete! 完成
Loaded plugins:fastestmirror
Loading mirrorspeeds from cached hostfile
* base: ftp.sjtu.edu.cn
* extras: mirror.bit.edu.cn
* updates: centos.ustc.edu.cn
Setting up InstallProcess
ResolvingDependencies
--> Runningtransaction check
---> Packagemysql-server.x86_64 0:5.1.73-5.el6_6 will be installed
--> ProcessingDependency: mysql = 5.1.73-5.el6_6 for package:mysql-server-5.1.73-5.el6_6.x86_64
--> ProcessingDependency: perl-DBI for package: mysql-server-5.1.73-5.el6_6.x86_64
--> ProcessingDependency: perl-DBD-MySQL for package: mysql-server-5.1.73-5.el6_6.x86_64
--> ProcessingDependency: perl(vars) for package: mysql-server-5.1.73-5.el6_6.x86_64
--> ProcessingDependency: perl(strict) for package: mysql-server-5.1.73-5.el6_6.x86_64
--> ProcessingDependency: perl(Sys::Hostname) for package: mysql-server-5.1.73-5.el6_6.x86_64
--> ProcessingDependency: perl(POSIX) for package: mysql-server-5.1.73-5.el6_6.x86_64
--> ProcessingDependency: perl(Getopt::Long) for package: mysql-server-5.1.73-5.el6_6.x86_64
--> ProcessingDependency: perl(File::Temp) for package: mysql-server-5.1.73-5.el6_6.x86_64
--> ProcessingDependency: perl(File::Path) for package: mysql-server-5.1.73-5.el6_6.x86_64
--> ProcessingDependency: perl(File::Copy) for package: mysql-server-5.1.73-5.el6_6.x86_64
--> ProcessingDependency: perl(File::Basename) for package:mysql-server-5.1.73-5.el6_6.x86_64
--> ProcessingDependency: perl(Data::Dumper) for package: mysql-server-5.1.73-5.el6_6.x86_64
--> ProcessingDependency: perl(DBI) for package: mysql-server-5.1.73-5.el6_6.x86_64
--> ProcessingDependency: libmysqlclient_r.so.16(libmysqlclient_16)(64bit) for package:mysql-server-5.1.73-5.el6_6.x86_64
--> ProcessingDependency: libmysqlclient.so.16(libmysqlclient_16)(64bit) for package:mysql-server-5.1.73-5.el6_6.x86_64
--> ProcessingDependency: /usr/bin/perl for package: mysql-server-5.1.73-5.el6_6.x86_64
--> ProcessingDependency: libmysqlclient_r.so.16()(64bit) for package:mysql-server-5.1.73-5.el6_6.x86_64
--> ProcessingDependency: libmysqlclient.so.16()(64bit) for package:mysql-server-5.1.73-5.el6_6.x86_64
--> Runningtransaction check
---> Packagemysql.x86_64 0:5.1.73-5.el6_6 will be installed
---> Packagemysql-libs.x86_64 0:5.1.73-5.el6_6 will be installed
---> Packageperl.x86_64 4:5.10.1-141.el6_7.1 will be installed
--> ProcessingDependency: perl-libs = 4:5.10.1-141.el6_7.1 for package:4:perl-5.10.1-141.el6_7.1.x86_64
--> ProcessingDependency: perl-libs for package: 4:perl-5.10.1-141.el6_7.1.x86_64
--> ProcessingDependency: perl(version) for package: 4:perl-5.10.1-141.el6_7.1.x86_64
--> ProcessingDependency: perl(Pod::Simple) for package: 4:perl-5.10.1-141.el6_7.1.x86_64
--> ProcessingDependency: perl(Module::Pluggable) for package:4:perl-5.10.1-141.el6_7.1.x86_64
--> ProcessingDependency: libperl.so()(64bit) for package: 4:perl-5.10.1-141.el6_7.1.x86_64
---> Packageperl-DBD-MySQL.x86_64 0:4.013-3.el6 will be installed
---> Packageperl-DBI.x86_64 0:1.609-4.el6 will be installed
--> Runningtransaction check
---> Packageperl-Module-Pluggable.x86_64 1:3.90-141.el6_7.1 will be installed
---> Packageperl-Pod-Simple.x86_64 1:3.13-141.el6_7.1 will be installed
--> ProcessingDependency: perl(Pod::Escapes) >= 1.04 for package:1:perl-Pod-Simple-3.13-141.el6_7.1.x86_64
---> Packageperl-libs.x86_64 4:5.10.1-141.el6_7.1 will be installed
---> Packageperl-version.x86_64 3:0.77-141.el6_7.1 will be installed
--> Runningtransaction check
---> Packageperl-Pod-Escapes.x86_64 1:1.04-141.el6_7.1 will be installed
--> FinishedDependency Resolution
DependenciesResolved
=======================================================================================================
Package Arch Version Repository Size
=======================================================================================================
Installing:
mysql-server x86_64 5.1.73-5.el6_6 base 8.6 M
Installing fordependencies:
mysql x86_64 5.1.73-5.el6_6 base 894 k
mysql-libs x86_64 5.1.73-5.el6_6 base 1.2 M
perl x86_64 4:5.10.1-141.el6_7.1 updates 10 M
perl-DBD-MySQL x86_64 4.013-3.el6 base 134 k
perl-DBI x86_64 1.609-4.el6 base 705 k
perl-Module-Pluggable x86_64 1:3.90-141.el6_7.1 updates 40 k
perl-Pod-Escapes x86_64 1:1.04-141.el6_7.1 updates 33 k
perl-Pod-Simple x86_64 1:3.13-141.el6_7.1 updates 213 k
perl-libs x86_64 4:5.10.1-141.el6_7.1 updates 579 k
perl-version x86_64 3:0.77-141.el6_7.1 updates 52 k
Transaction Summary
=======================================================================================================
Install 11 Package(s)
Total download size:23 M
Installed size: 69 M
DownloadingPackages:
(1/11):mysql-5.1.73-5.el6_6.x86_64.rpm
(2/11):mysql-libs-5.1.73-5.el6_6.x86_64.rpm
(3/11):mysql-server-5.1.73-5.el6_6.x86_64.rpm
(4/11):perl-5.10.1-141.el6_7.1.x86_64.rpm
(5/11):perl-DBD-MySQL-4.013-3.el6.x86_64.rpm
(6/11):perl-DBI-1.609-4.el6.x86_64.rpm
(7/11):perl-Module-Pluggable-3.90-141.el6_7.1.x86_64.rpm
(8/11):perl-Pod-Escapes-1.04-141.el6_7.1.x86_64.rpm
(9/11):perl-Pod-Simple-3.13-141.el6_7.1.x86_64.rpm
(10/11):perl-libs-5.10.1-141.el6_7.1.x86_64.rpm
(11/11):perl-version-0.77-141.el6_7.1.x86_64.rpm
--------------------------------------------------------------------------------------------------------
Total
Runningrpm_check_debug
Running TransactionTest
Transaction TestSucceeded
Running Transaction
Warning: RPMDBaltered outside of yum.
** Found 3pre-existing rpmdb problem(s), 'yum check' output follows:
2:postfix-2.6.6-2.2.el6_1.x86_64has missing requires of libmysqlclient.so.16()(64bit)
2:postfix-2.6.6-2.2.el6_1.x86_64has missing requires of libmysqlclient.so.16(libmysqlclient_16)(64bit)
2:postfix-2.6.6-2.2.el6_1.x86_64has missing requires of mysql-libs
Installing :mysql-libs-5.1.73-5.el6_6.x86_64
Installing :1:perl-Pod-Escapes-1.04-141.el6_7.1.x86_64
Installing :1:perl-Module-Pluggable-3.90-141.el6_7.1.x86_64
Installing :3:perl-version-0.77-141.el6_7.1.x86_64
Installing :4:perl-libs-5.10.1-141.el6_7.1.x86_64
Installing :1:perl-Pod-Simple-3.13-141.el6_7.1.x86_64
Installing :4:perl-5.10.1-141.el6_7.1.x86_64
Installing : perl-DBI-1.609-4.el6.x86_64
Installing :perl-DBD-MySQL-4.013-3.el6.x86_64
Installing : mysql-5.1.73-5.el6_6.x86_64
Installing :mysql-server-5.1.73-5.el6_6.x86_64
Verifying : 1:perl-Pod-Simple-3.13-141.el6_7.1.x86_64
Verifying : 1:perl-Pod-Escapes-1.04-141.el6_7.1.x86_64
Verifying : perl-DBD-MySQL-4.013-3.el6.x86_64
Verifying : mysql-5.1.73-5.el6_6.x86_64
Verifying : mysql-server-5.1.73-5.el6_6.x86_64
Verifying : perl-DBI-1.609-4.el6.x86_64
Verifying : mysql-libs-5.1.73-5.el6_6.x86_64
Verifying : 1:perl-Module-Pluggable-3.90-141.el6_7.1.x86_64
Verifying : 3:perl-version-0.77-141.el6_7.1.x86_64
Verifying : 4:perl-libs-5.10.1-141.el6_7.1.x86_64
Verifying : 4:perl-5.10.1-141.el6_7.1.x86_64
Installed:
mysql-server.x86_64 0:5.1.73-5.el6_6
DependencyInstalled:
mysql.x86_64 0:5.1.73-5.el6_6 mysql-libs.x86_640:5.1.73-5.el6_6 perl.x86
perl-DBI.x86_64 0:1.609-4.el6 perl-Module-Pluggable.x86_641:3.90-141.el6_7.1 perl-Pod
perl-libs.x86_64 4:5.10.1-141.el6_7.1 perl-version.x86_643:0.77-141.el6_7.1
Complete! 到此在线下载安装初步完成
4.启动MySql服务
[root@cnpc03 ~]# service mysqld start
Initializing MySQL database: Installing MySQL system tables...(安装 mysql 系统 表)
OK
Filling help tables...(初始化帮助表信息)
OK
To start mysqld atboot time you have to copy
support-files/mysql.serverto the right place for your system
PLEASE REMEMBER TOSET A PASSWORD FOR THE MySQL root USER !
To do so, start theserver, then issue the following commands:
/usr/bin/mysqladmin-u root password 'new-password' 修改密码
/usr/bin/mysqladmin-u root -h cnpc03 password 'new-password'(绑定主机名修改密码)
Alternatively youcan run:
/usr/bin/mysql_secure_installation
which will also giveyou the option of removing the test
databases andanonymous user created by default. Thisis
strongly recommendedfor production servers.
See the manual formore instructions.
You can start theMySQL daemon with:
cd /usr ;/usr/bin/mysqld_safe &
You can test theMySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ;perl mysql-test-run.pl
Please report anyproblems with the /usr/bin/mysqlbug script!
[ OK ]
Startingmysqld: [ OK ] 证明启动成功
5.默认root密码为空,建议先修改root 密码 参照 /usr/bin/mysqladmin-u root password 'new-password'
[root@cnpc03 ~]# /usr/bin/mysqladmin -u rootpassword 'root'
6.密码修改成功,牢记些密码,登录mysql
[root@cnpc03 ~]# mysql -u root -p
Enter password:
Welcome to the MySQLmonitor. Commands end with ; or \g.
Your MySQLconnection id is 3
Server version:5.1.73 Source distribution
Copyright (c) 2000,2013, Oracle and/or its affiliates. All rights reserved.
Oracle is aregistered trademark of Oracle Corporation and/or its
affiliates. Othernames may be trademarks of their respective
owners.
Type 'help;' or '\h'for help. Type '\c' to clear the current input statement.
登录成功
mysql>
7.默认安装完成,安全还存在问题,最好再再使用安全安装,按照提示一步步安装
[root@cnpc03~]# /usr/bin/mysql_secure_installation
NOTE: RUNNING ALLPARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log intoMySQL to secure it, we'll need the current
password for theroot user. If you've just installedMySQL, and
you haven't set theroot password yet, the password will be blank,
so you should justpress enter here.
Enter currentpassword for root (enter for none):
Setting the rootpassword ensures that nobody can log into the MySQL
root user withoutthe proper authorisation.
You already have aroot password set, so you can safely answer 'n'.
Change the root password? [Y/n] n(是否修改root密码,如果之前修改了就不用了)
Remove anonymous users? [Y/n] y (是否移除其它匿名用户,最好y 移除)
... Success!
Normally, rootshould only be allowed to connect from 'localhost'. This
ensures that someonecannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y(是否行程打开数据库,看需求,这里我打开了)
... Success!
By default, MySQLcomes with a database named 'test' that anyone can
access. This is also intended only for testing, andshould be removed
before moving into aproduction environment.
Remove test database and access to it? [Y/n] n (是否删除test 库 ,看需求,我选择不删除)
... skipping.
Reloading theprivilege tables will ensure that all changes made so far
will take effectimmediately.
Reload privilege tables now? [Y/n] (是否重新载入权限表) y
Cleaning up...
All done! If you've completed all of the above steps,your MySQL
installation shouldnow be secure.
Thanks for usingMySQL!
OK 安装成功!动手试试吧!