1. 首先配置一下 yum 的源,指向光驱。
(1) 光驱中放入系统盘
(2) mount -t iso9660 -o ro /dev/cdrom /mnt/cdrom
(3) 备份一下 yum 原始配置:
cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
(4) 修改配置 vim /etc/yum.repos.d/CentOS-Base.repo
在文件末尾添加如下内容:
[DVDROM]name=myyumbaseurl=file:///mnt/cdrom/gpgcheck=0enabled=1
好了,配置完成。
2. 使用 yum 命令安装 mysql
yum groupinstall mysql (此命令可以在电脑联网的情况下,不使用光驱进行网络下载和自动安装所有依赖包和主程序,安装的是官方提供的最新版本,对于版本号可以在过程当中发现。此次实验发现使用的是mysql5.0.77 是latest最近的版本)
分析完后,有个下载询问, 更新一点内容,内容不大。输入 y [回车]
mysql就自动装好了, 太方便了。
3. 查看一下有没有mysql服务
chkconfig --list | grep mysql
mysqld 0:off 1:off 2:off 3:off 4:off 5:off 6:off
4. 启动mysqld
/etc/init.d/mysqld start
starting MySQL: [ok]
5. 修改root账号密码
mysqladmin -u root password '123456'
6. 连接到mysql
mysql -u root -p
输入密码
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
此次实验自动下载和安装过程:
[root@localhost init.d]# yum groupinstall mysql
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.ustc.edu.cn
* extras: centos.ustc.edu.cn
* updates: centos.ustc.edu.cn
Setting up Group Process
Checking for new repos for mirrors
Package mysql-5.0.77-4.el5_6.6.i386 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package MySQL-python.i386 0:1.2.1-1 set to be updated
--> Processing Dependency: mx for package: MySQL-python
---> Package libdbi-dbd-mysql.i386 0:0.8.1a-1.2.2 set to be updated
--> Processing Dependency: libdbi-drivers = 0.8.1a-1.2.2 for package: libdbi-dbd-mysql
---> Package mysql-connector-odbc.i386 0:3.51.26r1127-1.el5 set to be updated
--> Processing Dependency: libltdl.so.3 for package: mysql-connector-odbc
---> Package mysql-server.i386 0:5.0.77-4.el5_6.6 set to be updated
---> Package perl-DBD-MySQL.i386 0:3.0007-2.el5 set to be updated
---> Package unixODBC.i386 0:2.2.11-7.1 set to be updated
--> Running transaction check
---> Package libdbi-drivers.i386 0:0.8.1a-1.2.2 set to be updated
--> Processing Dependency: libdbi >= 0.8 for package: libdbi-drivers
---> Package libtool-ltdl.i386 0:1.5.22-7.el5_4 set to be updated
---> Package mx.i386 0:2.0.6-2.2.2 set to be updated
--> Running transaction check
---> Package libdbi.i386 0:0.8.1-2.1 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
==========================================================================================
Package Arch Version Repository Size
==========================================================================================
Installing:
MySQL-python i386 1.2.1-1 base 82 k
libdbi-dbd-mysql i386 0.8.1a-1.2.2 base 17 k
mysql-connector-odbc i386 3.51.26r1127-1.el5 base 159 k
mysql-server i386 5.0.77-4.el5_6.6 base 9.8 M
perl-DBD-MySQL i386 3.0007-2.el5 base 148 k
unixODBC i386 2.2.11-7.1 base 832 k
Installing for dependencies:
libdbi i386 0.8.1-2.1 base 35 k
libdbi-drivers i386 0.8.1a-1.2.2 base 14 k
libtool-ltdl i386 1.5.22-7.el5_4 base 37 k
mx i386 2.0.6-2.2.2 base 558 k
Transaction Summary
==========================================================================================
Install 10 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 12 M
Is this ok [y/N]: y
Is this ok [y/N]: y
Downloading Packages:
(1/10): libdbi-drivers-0.8.1a-1.2.2.i386.rpm | 14 kB 00:00
(2/10): libdbi-dbd-mysql-0.8.1a-1.2.2.i386.rpm | 17 kB 00:00
(3/10): libdbi-0.8.1-2.1.i386.rpm | 35 kB 00:00
(4/10): libtool-ltdl-1.5.22-7.el5_4.i386.rpm | 37 kB 00:00
(5/10): MySQL-python-1.2.1-1.i386.rpm | 82 kB 00:00
(6/10): perl-DBD-MySQL-3.0007-2.el5.i386.rpm | 148 kB 00:00
(7/10): mysql-connector-odbc-3.51.26r1127-1.el5.i386.rpm | 159 kB 00:00
(8/10): mx-2.0.6-2.2.2.i386.rpm | 558 kB 00:00
(9/10): unixODBC-2.2.11-7.1.i386.rpm | 832 kB 00:00
(10/10): mysql-server-5.0.77-4.el5_6.6.i386.rpm | 9.8 MB 00:04
------------------------------------------------------------------------------------------
Total 1.9 MB/s | 12 MB 00:06
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : mx 1/10
Installing : perl-DBD-MySQL 2/10
Installing : libdbi 3/10
Installing : libtool-ltdl 4/10
Installing : unixODBC 5/10
Installing : mysql-connector-odbc 6/10
Installing : mysql-server 7/10
Installing : MySQL-python 8/10
Installing : libdbi-drivers 9/10
Installing : libdbi-dbd-mysql 10/10
Installed:
MySQL-python.i386 0:1.2.1-1 libdbi-dbd-mysql.i386 0:0.8.1a-1.2.2
mysql-connector-odbc.i386 0:3.51.26r1127-1.el5 mysql-server.i386 0:5.0.77-4.el5_6.6
perl-DBD-MySQL.i386 0:3.0007-2.el5 unixODBC.i386 0:2.2.11-7.1
Dependency Installed:
libdbi.i386 0:0.8.1-2.1 libdbi-drivers.i386 0:0.8.1a-1.2.2
libtool-ltdl.i386 0:1.5.22-7.el5_4 mx.i386 0:2.0.6-2.2.2
Complete!
[root@localhost init.d]# chkconfig --list | grep mysql
mysqld 0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭
若想在3级别下自动开启,命令如下:
[root@localhost ~]# chkconfig --level 3 mysqld on
[root@localhost ~]# chkconfig --list | grep mysql
mysqld 0:关闭 1:关闭 2:关闭 3:启用 4:关闭 5:关闭 6:关闭