你的位置:首页 > 软件开发 > 数据库 > Linux CentOS6.4下Mysql数据库的安装与配置

Linux CentOS6.4下Mysql数据库的安装与配置

发布时间:2015-11-21 23:00:04
一、mysql简介说到数据库,我们大多想到的是关系型数据库,比如mysql、oracle、sqlserver等等,这些数据库软件在windows上安装都非常的方便,在Linux上如果要安装数据库,咱不得不首先推荐的是mysql数据库了,而且Mysql数据库的第一个版本就是发行在L ...

Linux CentOS6.4下Mysql数据库的安装与配置

一、mysql简介

说到数据库,我们大多想到的是关系型数据库,比如mysql、oracle、sqlserver等等,这些数据库软件在windows上安装都非常的方便,在Linux上如果要安装数据库,咱不得不首先推荐的是mysql数据库了,而且Mysql数据库的第一个版本就是发行在Linux系统上的。

MySQL是一个关系型数据库管理系统,由瑞典MySQL AB公司开发,目前属于Oracle公司。MySQL是一种关联数据库管理系统,关联数据库将数据保存在不同的表中,而不是将所有数据放在一个大仓库内,这样就增加了速度并提高了灵活性。MySQL的SQL语言是用于访问数据库的最常用标准化语言。MySQL软件采用了双授权政策(本词条“授权政策”),它分为社区版和商业版,由于其体积小、速度快、总体拥有成本低,尤其是开放源码这一特点,一般中小型网站的开发都选择MySQL作为网站数据库。由于其社区版的性能卓越,搭配PHP和Apache可组成良好的开发环境。

在Linux上安装mysql数据库,我们可以去其官网上下载mysql数据库的rpm包,http://dev.mysql.com/downloads/mysql/5.6.html#downloads,大家可以根据自己的操作系统去下载对应的数据库文件,目前最新的版本是5.6.10了。

在这里我是通过yum来进行mysql数据库的安装的,通过这种方式进行安装,可以将跟mysql相关的一些服务、jar包都给我们安装好,所以省去了很多不必要的麻烦!!!

二、卸载掉原有mysql

因为mysql数据库在Linux上实在是太流行了,所以目前下载的主流Linux系统版本基本上都集成了mysql数据库在里面,我们可以通过如下命令来查看我们的操作系统上是否已经安装了mysql数据库

[root@xiaoluo ~]# rpm -qa | grep mysql  // 这个命令就会查看该操作系统上是否已经安装了mysql数据库
[root@xiaoluo ~]# service mysqld start初始化 MySQL 数据库: WARNING: The host 'xiaoluo' could not be looked up with resolveip.This probably means that your libc libraries are not 100 % compatiblewith this binary MySQL version. The MySQL daemon, mysqld, should worknormally with the exception that host name resolving will not work.This means that you should use IP addresses instead of hostnameswhen specifying MySQL privileges !Installing MySQL system tables...OKFilling help tables...OKTo start mysqld at boot time you have to copysupport-files/mysql.server to the right place for your systemPLEASE 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 xiaoluo password 'new-password'Alternatively you can run:/usr/bin/mysql_secure_installationwhich will also give you the option of removing the testdatabases and anonymous user created by default. This isstrongly 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.plcd /usr/mysql-test ; perl mysql-test-run.plPlease report any problems with the /usr/bin/mysqlbug script!                              [确定]正在启动 mysqld:                      [确定]
Linux CentOS6.4下Mysql数据库的安装与配置

 

这时我们会看到第一次启动mysql服务器以后会提示非常多的信息,目的就是对mysql数据库进行初始化操作,当我们再次重新启动mysql服务时,就不会提示这么多信息了,如:

 

[root@xiaoluo ~]# service mysqld restart停止 mysqld:                       [确定]正在启动 mysqld:                     [确定]
[root@xiaoluo etc]# ls my.cnf my.cnf
[root@xiaoluo ~]# cd /var/lib/mysql/[root@xiaoluo mysql]# ls -l总用量 20488-rw-rw----. 1 mysql mysql 10485760 4月  6 22:01 ibdata1-rw-rw----. 1 mysql mysql 5242880 4月  6 22:01 ib_logfile0-rw-rw----. 1 mysql mysql 5242880 4月  6 21:59 ib_logfile1drwx------. 2 mysql mysql   4096 4月  6 21:59 mysql  // 这两个是mysql数据库安装时默认的两个数据库文件srwxrwxrwx. 1 mysql mysql    0 4月  6 22:01 mysql.sockdrwx------. 2 mysql mysql   4096 4月  6 21:59 test  // 这两个是mysql数据库安装时默认的两个数据库文件
Linux CentOS6.4下Mysql数据库的安装与配置

 

我们可以自己创建一个数据库,来验证一下该数据库文件的存放位置

 

Linux CentOS6.4下Mysql数据库的安装与配置
[root@xiaoluo xiaoluo]# cd [root@xiaoluo ~]# cd /var/log[root@xiaoluo log]# lsamanda        cron      maillog-20130331  spice-vdagent.loganaconda.ifcfg.log  cron-20130331 mcelog       spooleranaconda.log     cups      messages      spooler-20130331anaconda.program.log dirsrv     messages-20130331 sssdanaconda.storage.log dmesg     mysqld.log     tallyloganaconda.syslog    dmesg.old   ntpstats      tomcat6anaconda.xlog     dracut.log   piranha      wpa_supplicant.loganaconda.yum.log   gdm      pm-powersave.log  wtmpaudit         httpd     ppp        Xorg.0.logboot.log       ibacm.log   prelink      Xorg.0.log.oldbtmp         lastlog    sa         Xorg.1.logbtmp-20130401     libvirt    samba       Xorg.2.logcluster        luci      secure       Xorg.9.logConsoleKit      maillog    secure-20130331  yum.log
Linux CentOS6.4下Mysql数据库的安装与配置

 

其中mysqld.log 这个文件就是我们存放我们跟mysql数据库进行操作而产生的一些日志信息,通过查看该日志文件,我们可以从中获得很多信息

 

因为我们的mysql数据库是可以通过网络访问的,并不是一个单机版数据库,其中使用的协议是 tcp/ip 协议,我们都知道mysql数据库绑定的端口号是 3306 ,所以我们可以通过 netstat -anp 命令来查看一下,Linux系统是否在监听 3306 这个端口号:

Linux CentOS6.4下Mysql数据库的安装与配置

结果如上所示,Linux系统监听的3306端口号就是我们的mysql数据库!!!!


原标题:Linux CentOS6.4下Mysql数据库的安装与配置

关键词:MYSQL

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。