CentOS - 安装mysql
mysql是应用比较多的数据库之一,今天就在CentOS6.4 32bit系统上安装下mysql。
首先来说下,mysql可以从官网去下载相应版本进行安装,也可以创建yum仓库后从自己的yum仓库中进行安装。
因为我之前创建了自己的yum仓库,就不进行下载了。
1 查看mysql相关的安装包有哪些:
所用命令:yum list | grep mysql
[root@eccl warjun]# yum list | grep mysql
mysql-libs.i686 5.1.66-2.el6_3 @anaconda-CentOS-201303020136.i386/6.4
dovecot-mysql.i686 1:2.0.9-5.el6 myyum
libdbi-dbd-mysql.i686 0.8.3-5.1.el6 myyum
mod_auth_mysql.i686 1:3.0.0-11.el6_0.1
mysql.i686 5.1.66-2.el6_3 myyum
mysql-bench.i686 5.1.66-2.el6_3 myyum
mysql-connector-java.noarch
mysql-connector-odbc.i686
mysql-devel.i686 5.1.66-2.el6_3 myyum
mysql-server.i686 5.1.66-2.el6_3 myyum
mysql-test.i686 5.1.66-2.el6_3 myyum
php-mysql.i686 5.3.3-22.el6 myyum
qt-mysql.i686 1:4.6.2-25.el6 myyum
rsyslog-mysql.i686 5.8.10-6.el6 myyum
2 安装
我们选择mysql-server.i686 (mysql的服务端),mysql.i686 (mysql的客户端),mysql-devel.i686 (开发的库文件)进行安装。
安装用到的命令:
yum install -y mysql-server mysql mysql-devel
执行后yum会为我们解决一些安装依赖包,等待一会会提示安装完成。
3 查看安装的mysql
安装好之后来查看下,用到的命令:rpm -qi mysql-server
Complete!
[root@eccl warjun]# rpm -qi mysql-server
Name : mysql-server Relocations: (not relocatable)
Version : 5.1.66 Vendor: CentOS
Release : 2.el6_3 Build Date: Fri 07 Dec 2012 11:27:50 PM CST
Install Date: Sat 12 Oct 2013 07:10:36 PM CST Build Host: c6b8.bsys.dev.centos.org
Group : Applications/Databases Source RPM: mysql-5.1.66-2.el6_3.src.rpm
Size : 25636721 License: GPLv2 with exceptions
Signature : RSA/SHA1, Sat 08 Dec 2012 12:23:07 AM CST, Key ID 0946fca2c105b9de
Packager : CentOS BuildSystem <http://bugs.centos.org>
URL : http://www.mysql.com
Summary : The MySQL server and related files
Description :
MySQL is a multi-user, multi-threaded SQL database server. MySQL is a
client/server implementation consisting of a server daemon (mysqld)
and many different client programs and libraries. This package contains
the MySQL server and some accompanying files and directories.
好了,这样mysql就安装成功了。
4 设置——mysql的初始化
启动mysql服务,用到的命令:service mysqld start
如果是第一次启动会有很多初始化的输出,再次重启就不会有这样多的信息了:
[root@eccl warjun]# 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 eccl.com 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 ]
[root@eccl warjun]# service mysqld restart
Stopping mysqld: [ OK ]
Starting mysqld: [ OK ]
下面给mysql来设置root用户的密码,用到的命令:
mysqladmin -u root password 'rootpassword'
设置好密码之后来登录下试试,
用到的登录命令:mysql -u root -p
输入之前设置的命令可以成功登录。
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
3 rows in set (0.00 sec)
mysql> quit
Bye
[root@eccl warjun]#
好了,可以看到mysql已经可以使用了。