第一步,用centos安装好mysql.
用yum方法实现。
yum list | grep mysql
然后我们可以通过输入
yum install -y mysql-server mysql mysql-devel
命令将mysql mysql-server mysql-devel都安装好(注意:安装mysql时我们并不是安装了mysql客户端就相当于安装好了mysql数据库了,我们还需要安装mysql-server服务端才行)
Loaded plugins: fastestmirror
Setting up Install Process
Loading mirror speeds from cached hostfile
* base: muug.ca
* extras: muug.ca
* updates: muug.ca
Resolving Dependencies
--> Running transaction check
---> Package mysql.x86_64 0:5.1.73-7.el6 will be installed
--> Processing Dependency: mysql-libs = 5.1.73-7.el6 for package: mysql-5.1.73-7.el6.x86_64
--> Processing Dependency: libmysqlclient_r.so.16(libmysqlclient_16)(64bit) for package: mysql-5.1.73-7.el6.x86_64
--> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16)(64bit) for package: mysql-5.1.73-7.el6.x86_64
--> Processing Dependency: libmysqlclient_r.so.16()(64bit) for package: mysql-5.1.73-7.el6.x86_64
--> Processing Dependency: libmysqlclient.so.16()(64bit) for package: mysql-5.1.73-7.el6.x86_64
---> Package mysql-devel.x86_64 0:5.1.73-7.el6 will be installed
--> Processing Dependency: openssl-devel for package: mysql-devel-5.1.73-7.el6.x86_64
---> Package mysql-server.x86_64 0:5.1.73-7.el6 will be installed
--> Processing Dependency: perl-DBI for package: mysql-server-5.1.73-7.el6.x86_64
--> Processing Dependency: perl-DBD-MySQL for package: mysql-server-5.1.73-7.el6.x86_64
--> Processing Dependency: perl(DBI) for package: mysql-server-5.1.73-7.el6.x86_64
--> Running transaction check
---> Package mysql-libs.x86_64 0:5.1.73-7.el6 will be installed
---> Package openssl-devel.x86_64 0:1.0.1e-48.el6_8.3 will be installed
--> Processing Dependency: openssl = 1.0.1e-48.el6_8.3 for package: openssl-devel-1.0.1e-48.el6_8.3.x86_64
--> Processing Dependency: zlib-devel for package: openssl-devel-1.0.1e-48.el6_8.3.x86_64
--> Processing Dependency: krb5-devel for package: openssl-devel-1.0.1e-48.el6_8.3.x86_64
---> Package perl-DBD-MySQL.x86_64 0:4.013-3.el6 will be installed
---> Package perl-DBI.x86_64 0:1.609-4.el6 will be installed
--> Running transaction check
---> Package krb5-devel.x86_64 0:1.10.3-57.el6 will be installed
--> Processing Dependency: krb5-libs = 1.10.3-57.el6 for package: krb5-devel-1.10.3-57.el6.x86_64
--> Processing Dependency: libselinux-devel for package: krb5-devel-1.10.3-57.el6.x86_64
--> Processing Dependency: libcom_err-devel for package: krb5-devel-1.10.3-57.el6.x86_64
--> Processing Dependency: keyutils-libs-devel for package: krb5-devel-1.10.3-57.el6.x86_64
---> Package openssl.x86_64 0:1.0.1e-30.el6_6.4 will be updated
---> Package openssl.x86_64 0:1.0.1e-48.el6_8.3 will be an update
---> Package zlib-devel.x86_64 0:1.2.3-29.el6 will be installed
--> Running transaction check
---> Package keyutils-libs-devel.x86_64 0:1.4-5.el6 will be installed
---> Package krb5-libs.x86_64 0:1.10.3-33.el6 will be updated
---> Package krb5-libs.x86_64 0:1.10.3-57.el6 will be an update
---> Package libcom_err-devel.x86_64 0:1.41.12-22.el6 will be installed
--> Processing Dependency: libcom_err = 1.41.12-22.el6 for package: libcom_err-devel-1.41.12-22.el6.x86_64
---> Package libselinux-devel.x86_64 0:2.0.94-7.el6 will be installed
--> Processing Dependency: libselinux = 2.0.94-7.el6 for package: libselinux-devel-2.0.94-7.el6.x86_64
--> Processing Dependency: libsepol-devel >= 2.0.32-1 for package: libselinux-devel-2.0.94-7.el6.x86_64
--> Processing Dependency: pkgconfig(libsepol) for package: libselinux-devel-2.0.94-7.el6.x86_64
--> Running transaction check
---> Package libcom_err.i686 0:1.41.12-21.el6 will be updated
--> Processing Dependency: libcom_err = 1.41.12-21.el6 for package: e2fsprogs-1.41.12-21.el6.x86_64
--> Processing Dependency: libcom_err = 1.41.12-21.el6 for package: e2fsprogs-libs-1.41.12-21.el6.x86_64
--> Processing Dependency: libcom_err = 1.41.12-21.el6 for package: e2fsprogs-libs-1.41.12-21.el6.i686
--> Processing Dependency: libcom_err = 1.41.12-21.el6 for package: libss-1.41.12-21.el6.x86_64
---> Package libcom_err.x86_64 0:1.41.12-21.el6 will be updated
---> Package libcom_err.i686 0:1.41.12-22.el6 will be an update
---> Package libcom_err.x86_64 0:1.41.12-22.el6 will be an update
---> Package libselinux.i686 0:2.0.94-5.8.el6 will be updated
--> Processing Dependency: libselinux = 2.0.94-5.8.el6 for package: libselinux-utils-2.0.94-5.8.el6.x86_64
---> Package libselinux.x86_64 0:2.0.94-5.8.el6 will be updated
---> Package libselinux.i686 0:2.0.94-7.el6 will be an update
---> Package libselinux.x86_64 0:2.0.94-7.el6 will be an update
---> Package libsepol-devel.x86_64 0:2.0.41-4.el6 will be installed
--> Running transaction check
---> Package e2fsprogs.x86_64 0:1.41.12-21.el6 will be updated
---> Package e2fsprogs.x86_64 0:1.41.12-22.el6 will be an update
---> Package e2fsprogs-libs.i686 0:1.41.12-21.el6 will be updated
---> Package e2fsprogs-libs.x86_64 0:1.41.12-21.el6 will be updated
---> Package e2fsprogs-libs.i686 0:1.41.12-22.el6 will be an update
---> Package e2fsprogs-libs.x86_64 0:1.41.12-22.el6 will be an update
---> Package libselinux-utils.x86_64 0:2.0.94-5.8.el6 will be updated
---> Package libselinux-utils.x86_64 0:2.0.94-7.el6 will be an update
---> Package libss.x86_64 0:1.41.12-21.el6 will be updated
---> Package libss.x86_64 0:1.41.12-22.el6 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
mysql x86_64 5.1.73-7.el6 base 894 k
mysql-devel x86_64 5.1.73-7.el6 base 130 k
mysql-server x86_64 5.1.73-7.el6 base 8.6 M
Installing for dependencies:
keyutils-libs-devel x86_64 1.4-5.el6 base 29 k
krb5-devel x86_64 1.10.3-57.el6 base 504 k
libcom_err-devel x86_64 1.41.12-22.el6 base 33 k
libselinux-devel x86_64 2.0.94-7.el6 base 137 k
libsepol-devel x86_64 2.0.41-4.el6 base 64 k
mysql-libs x86_64 5.1.73-7.el6 base 1.2 M
openssl-devel x86_64 1.0.1e-48.el6_8.3 updates 1.2 M
perl-DBD-MySQL x86_64 4.013-3.el6 base 134 k
perl-DBI x86_64 1.609-4.el6 base 705 k
zlib-devel x86_64 1.2.3-29.el6 base 44 k
Updating for dependencies:
e2fsprogs x86_64 1.41.12-22.el6 base 554 k
e2fsprogs-libs i686 1.41.12-22.el6 base 128 k
e2fsprogs-libs x86_64 1.41.12-22.el6 base 121 k
krb5-libs x86_64 1.10.3-57.el6 base 770 k
libcom_err i686 1.41.12-22.el6 base 37 k
libcom_err x86_64 1.41.12-22.el6 base 37 k
libselinux i686 2.0.94-7.el6 base 109 k
libselinux x86_64 2.0.94-7.el6 base 109 k
libselinux-utils x86_64 2.0.94-7.el6 base 82 k
libss x86_64 1.41.12-22.el6 base 42 k
openssl x86_64 1.0.1e-48.el6_8.3 updates 1.5 M
Transaction Summary
================================================================================
Install 13 Package(s)
Upgrade 11 Package(s)
Total download size: 17 M
Downloading Packages:
--------------------------------------------------------------------------------
Total 3.3 MB/s | 17 MB 00:05
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Updating : libcom_err-1.41.12-22.el6.x86_64 1/35
Updating : libselinux-2.0.94-7.el6.x86_64 2/35
Updating : krb5-libs-1.10.3-57.el6.x86_64 3/35
Updating : openssl-1.0.1e-48.el6_8.3.x86_64 4/35
Installing : mysql-libs-5.1.73-7.el6.x86_64 5/35
Installing : mysql-5.1.73-7.el6.x86_64 6/35
Installing : perl-DBI-1.609-4.el6.x86_64 7/35
Installing : perl-DBD-MySQL-4.013-3.el6.x86_64 8/35
Updating : libss-1.41.12-22.el6.x86_64 9/35
Installing : libcom_err-devel-1.41.12-22.el6.x86_64 10/35
Updating : e2fsprogs-libs-1.41.12-22.el6.x86_64 11/35
Installing : libsepol-devel-2.0.41-4.el6.x86_64 12/35
Installing : libselinux-devel-2.0.94-7.el6.x86_64 13/35
Installing : zlib-devel-1.2.3-29.el6.x86_64 14/35
Installing : keyutils-libs-devel-1.4-5.el6.x86_64 15/35
Installing : krb5-devel-1.10.3-57.el6.x86_64 16/35
Installing : openssl-devel-1.0.1e-48.el6_8.3.x86_64 17/35
Updating : libcom_err-1.41.12-22.el6.i686 18/35
Installing : mysql-devel-5.1.73-7.el6.x86_64 19/35
Updating : e2fsprogs-1.41.12-22.el6.x86_64 20/35
Installing : mysql-server-5.1.73-7.el6.x86_64 21/35
Updating : libselinux-utils-2.0.94-7.el6.x86_64 22/35
Updating : e2fsprogs-libs-1.41.12-22.el6.i686 23/35
Updating : libselinux-2.0.94-7.el6.i686 24/35
Cleanup : e2fsprogs-libs-1.41.12-21.el6 25/35
Cleanup : libcom_err-1.41.12-21.el6 26/35
Cleanup : libselinux-2.0.94-5.8.el6 27/35
Cleanup : e2fsprogs-1.41.12-21.el6.x86_64 28/35
Cleanup : openssl-1.0.1e-30.el6_6.4.x86_64 29/35
Cleanup : krb5-libs-1.10.3-33.el6.x86_64 30/35
Cleanup : e2fsprogs-libs-1.41.12-21.el6 31/35
Cleanup : libss-1.41.12-21.el6.x86_64 32/35
Cleanup : libselinux-utils-2.0.94-5.8.el6.x86_64 33/35
Cleanup : libselinux-2.0.94-5.8.el6 34/35
Cleanup : libcom_err-1.41.12-21.el6 35/35
Verifying : perl-DBD-MySQL-4.013-3.el6.x86_64 1/35
Verifying : perl-DBI-1.609-4.el6.x86_64 2/35
Verifying : libselinux-2.0.94-7.el6.i686 3/35
Verifying : mysql-5.1.73-7.el6.x86_64 4/35
Verifying : keyutils-libs-devel-1.4-5.el6.x86_64 5/35
Verifying : libss-1.41.12-22.el6.x86_64 6/35
Verifying : zlib-devel-1.2.3-29.el6.x86_64 7/35
Verifying : krb5-devel-1.10.3-57.el6.x86_64 8/35
Verifying : mysql-libs-5.1.73-7.el6.x86_64 9/35
Verifying : libcom_err-devel-1.41.12-22.el6.x86_64 10/35
Verifying : openssl-1.0.1e-48.el6_8.3.x86_64 11/35
Verifying : e2fsprogs-libs-1.41.12-22.el6.i686 12/35
Verifying : e2fsprogs-1.41.12-22.el6.x86_64 13/35
Verifying : libcom_err-1.41.12-22.el6.i686 14/35
Verifying : libsepol-devel-2.0.41-4.el6.x86_64 15/35
Verifying : libselinux-utils-2.0.94-7.el6.x86_64 16/35
Verifying : openssl-devel-1.0.1e-48.el6_8.3.x86_64 17/35
Verifying : mysql-server-5.1.73-7.el6.x86_64 18/35
Verifying : libselinux-2.0.94-7.el6.x86_64 19/35
Verifying : libcom_err-1.41.12-22.el6.x86_64 20/35
Verifying : libselinux-devel-2.0.94-7.el6.x86_64 21/35
Verifying : mysql-devel-5.1.73-7.el6.x86_64 22/35
Verifying : krb5-libs-1.10.3-57.el6.x86_64 23/35
Verifying : e2fsprogs-libs-1.41.12-22.el6.x86_64 24/35
Verifying : e2fsprogs-1.41.12-21.el6.x86_64 25/35
Verifying : e2fsprogs-libs-1.41.12-21.el6.i686 26/35
Verifying : libcom_err-1.41.12-21.el6.x86_64 27/35
Verifying : libselinux-utils-2.0.94-5.8.el6.x86_64 28/35
Verifying : libselinux-2.0.94-5.8.el6.i686 29/35
Verifying : openssl-1.0.1e-30.el6_6.4.x86_64 30/35
Verifying : e2fsprogs-libs-1.41.12-21.el6.x86_64 31/35
Verifying : libss-1.41.12-21.el6.x86_64 32/35
Verifying : libselinux-2.0.94-5.8.el6.x86_64 33/35
Verifying : libcom_err-1.41.12-21.el6.i686 34/35
Verifying : krb5-libs-1.10.3-33.el6.x86_64 35/35
Installed:
mysql.x86_64 0:5.1.73-7.el6 mysql-devel.x86_64 0:5.1.73-7.el6
mysql-server.x86_64 0:5.1.73-7.el6
Dependency Installed:
keyutils-libs-devel.x86_64 0:1.4-5.el6
krb5-devel.x86_64 0:1.10.3-57.el6
libcom_err-devel.x86_64 0:1.41.12-22.el6
libselinux-devel.x86_64 0:2.0.94-7.el6
libsepol-devel.x86_64 0:2.0.41-4.el6
mysql-libs.x86_64 0:5.1.73-7.el6
openssl-devel.x86_64 0:1.0.1e-48.el6_8.3
perl-DBD-MySQL.x86_64 0:4.013-3.el6
perl-DBI.x86_64 0:1.609-4.el6
zlib-devel.x86_64 0:1.2.3-29.el6
Dependency Updated:
e2fsprogs.x86_64 0:1.41.12-22.el6 e2fsprogs-libs.i686 0:1.41.12-22.el6
e2fsprogs-libs.x86_64 0:1.41.12-22.el6 krb5-libs.x86_64 0:1.10.3-57.el6
libcom_err.i686 0:1.41.12-22.el6 libcom_err.x86_64 0:1.41.12-22.el6
libselinux.i686 0:2.0.94-7.el6 libselinux.x86_64 0:2.0.94-7.el6
libselinux-utils.x86_64 0:2.0.94-7.el6 libss.x86_64 0:1.41.12-22.el6
openssl.x86_64 0:1.0.1e-48.el6_8.3
Complete!
我们发现,通过yum方式安装mysql数据库省去了很多没必要的麻烦,当出现下面的结果时,就代表mysql数据库安装成功了
通过以下命令来判断我的mysql是否已经安装成功
rpm -qi mysql-server
启动mysql服务可以用以下命令
service mysqld start
会显示以下信息
[root /]# service mysqld start
Initializing MySQL database: Installing MySQL system tables...
OK
Filling help tables...
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 localhost.localdomain 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 with the /usr/bin/mysqlbug script!
[ OK ]
Starting mysqld: [ OK ]
重新启动mysqld
service mysqld restart
之后就是这些信息:
[root /]# service mysqld restart
Stopping mysqld: [ OK ]
Starting mysqld: [ OK ]
我们在使用mysql数据库时,都得首先启动mysqld服务,我们可以 通过 chkconfig --list | grep mysqld
命令来查看mysql服务是不是开机自动启动,如:
[root /]# chkconfig --list | grep mysqld
mysqld 0:off 1:off 2:off 3:off 4:off 5:off 6:off
开机自启动
chkconfig mysqld on
检查以下
chkconfig --list | grep mysql
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
第二步
http://www.cnblogs.com/xiaoluo501395377/archive/2013/04/07/3003278.html