日期:2014-05-16  浏览次数:20463 次

linux 下 mysql数据库安装及配置 总结

近期由于工作需要,加上偶上辈子修来的福分,让偶一个坐coder的,去linux下配置运行环境。故,经历了些事,且总结了点东东,今晚有机会写下点东东,与各位分享一下...

?

在linux环境下,在进行mysql数据库的安装前,请确认当前linux下,没有mysql的安装版本,或之前旧版本的mysql已经卸载完全。

有关如何在linux下卸载mysql,可以参考我的另一篇博文 http://syc001.iteye.com/admin/blogs/1149267

?

ok,进入正题:

/*****----------------? mysql setup begin? -------------------*****/

?

1:需要先查看LINUX的版本, 使用如下命令
[ysong@sva_rec mysql]# lsb_release -a

?

LSB Version: :core-3.1-amd64:core-3.1-ia32:core-3.1-noarch:graphics-3.1-amd64:graphics-3.1-ia32:graphics-3.1-noarch Distributor ID: RedHatEnterpriseServer Description: Red Hat Enterprise Linux Server release 5.2 (Tikanga) Release: 5.2 Codename: Tikanga

?


?然后,去mysql官网http://dev.mysql.com/downloads/mysql/下载MySQL的相应版本的安装文件.

一般情况下,下载两个和linux系统相对应的mysql安装文件即可。分别是server和client版本。具体文件见2.

?

?

2:这里,我将下载后的对应的安装文件放到linux下自定义的一个新建的文件夹mysql下。
使用命令安装相应的rpm文件。在mysql文件路径下,输入如下命令,即可

?


首先,安装服务器端 :
[ysong@sva_rec mysql]#rpm -ivh MySQL-server-community-5.1.58-1.rhel5.x86_64.rpm


其次,安装客户端 :
[ysong@sva_rec mysql]#rpm -ivh MySQL-client-community-5.1.58-1.rhel5.x86_64.rpm

?

?

?

3:安装完成后,
mysql安装目录可能在:/usr/bin/mysql?
mysql启动文件可能在: /etc/rc.d/init.d/mysqld
可以使用whereis mysql命令来查找它安装的路径

可以使用命令 rpm -qal | grep mysql 确定linux下已安装MYSQL的安装路径,Eg:
[ysong@sva_rec mysql]# rpm -qal | grep mysql

?

//使用如下命令查看系统是否已经安装mysql
[ysong@sva_rec mysql]# rpm –qa | grep mysql

?

或键入命令:

[ysong@sva_rec mysql]$ netstat -nat

tcp 0 0 127.0.0.1:3306 127.0.0.1:33648 ESTABLISHED tcp 0 0 127.0.0.1:3306 127.0.0.1:33649 ESTABLISHED

?


出现以上内容。?

?

或,直接敲入命令mysql+回车

?

[ysong@IDC ~]$mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 5136 Server version: 5.1.58-community MySQL Community Server (GPL) Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. This software comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to modify and redistribute it under the GPL v2 license Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>

?


?

出现此情此景,即表示linux下mysql安装成功