手机版
你好,游客 登录 注册
背景:
阅读新闻

CentOS下使用rpm包安装MySQL

[日期:2015-01-29] 来源:Linux社区  作者:Linux [字体:大 中 小]

CentOS下安装MySQL步骤:

第一、 http://www.mysql.com/downloads/mysql-4.0.html下载MySQL-client-5.0.96-1.glibc23.x86_64.rpm和

MySQL-server-5.0.96-1.glibc23.x86_64.rpm

第二、安装服务端:

[root@linuxidc mysql]# rpm -ivh MySQL-server-5.1.73-1.glibc23.i386.rpm

          显示信息:


Preparing...                ########################################### [100%]
    1:MySQL-server          ########################################### [100%]
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
。。。。。
Please report any problems with the /usr/bin/mysqlbug script!

如出现如上信息,则表示服务器端安装成功。

安装客户端:[root@linuxidc mysql]# rpm -ivh MySQL-client-5.1.73-1.glibc23.i386.rpm

显示如下信息则表明安装成功:

Preparing...                ########################################### [100%]
    1:MySQL-client          ########################################### [100%]

若安装过程中报该错误!!!

file /usr/share/mysql/czech/errmsg.sys from install of MySQL-server-5.1.73-1.glibc.i386 conflicts with file from package mysql-libs-5.1.73-1.glibc.i386

原因:已存在mysql-libs-5.1.73-1.glibc.i386的库(这是linux自带的)所以需要先删除以前的库才能安装

rpm -e mysql-libs-5.1.73-1.glibc.i386 --nodeps 强制卸载!

第三、启动mysql服务

[root@linuxidc sean]# /etc/init.d/mysql start 或者

[root@linuxidc sean]# mysqld_safe &

通过netstat命令查看mysql是否启动成功

[sean@linuxidc ~]$ netstat -nat
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address              Foreign Address            State     
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                  LISTEN     
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                  LISTEN     
tcp        0      0 127.0.0.1:631              0.0.0.0:*                  LISTEN     
tcp        0      0 127.0.0.1:6010              0.0.0.0:*                  LISTEN     
tcp        0    52 192.168.1.128:22            192.168.1.106:51488        ESTABLISHED
tcp        1      0 192.168.1.128:38414        23.2.16.57:80              CLOSE_WAIT 
tcp        0      0 :::22                      :::*                        LISTEN     
tcp        0      0 ::1:631                    :::*                        LISTEN     
tcp        0      0 ::1:6010                    :::*                        LISTEN

mysql默认端口号为3306,以上信息中出现3306端口号,则启动成功

查看mysql进程:

[root@linuxidc sean]# ps -e

第四、停止mysql服务:

[root@linuxidc sean]# /usr/bin/mysqladmin -u root -p shutdown

重启mysql服务:/etc/init.d/mysql restart

第五、重启linux之后,启动mysql服务

[root@linuxidc sean]# /usr/init.d/mysql start

[root@linuxidc mysql]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.73 MySQL Community Server (GPL)
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

退出mysql:

mysql> exit

设置mysql密码

[root@linuxidc mysql]# /usr/bin/mysqladmin -u root password '*****'

登录mysql

[root@linuxidc mysql]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.73 MySQL Community Server (GPL)
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

出现以上信息表明登录成功!!!

第六、卸载mysql

用rpm包卸载:

[root@linuxidc sean]# rpm -qa|grep MySQL
MySQL-client-5.1.73-1.glibc23.i386
MySQL-server-5.1.73-1.glibc23.i386

执行此命令卸载 [root@linuxidc sean]# rpm -e --nodeps MySQL-client-5.1.73-1.glibc23.i386 

[root@linuxidc sean]# find / -name mysql
/var/lib/mysql
/var/lib/mysql/mysql
/var/lock/subsys/mysql
/usr/lib/mysql
/usr/share/mysql
/usr/mysql
/usr/bin/mysql
/etc/logrotate.d/mysql
/etc/rc.d/init.d/mysql

可以手动删除mysql相关的文件

[root@linuxidc sean]# rm -rf /var/lib/mysql

后面的操作mysql和windows下一样了。。。

--------------------------------------分割线 --------------------------------------

MySQL5.7.3.0安装配置图解教程 http://www.linuxidc.com/Linux/2014-10/108397.htm

Ubuntu 14.04下安装MySQL http://www.linuxidc.com/Linux/2014-05/102366.htm

《MySQL权威指南(原书第2版)》清晰中文扫描版 PDF http://www.linuxidc.com/Linux/2014-03/98821.htm

Ubuntu 14.04 LTS 安装 LNMP Nginx\PHP5 (PHP-FPM)\MySQL http://www.linuxidc.com/Linux/2014-05/102351.htm

Ubuntu 14.04下搭建MySQL主从服务器 http://www.linuxidc.com/Linux/2014-05/101599.htm

Ubuntu 12.04 LTS 构建高可用分布式 MySQL 集群 http://www.linuxidc.com/Linux/2013-11/93019.htm

Ubuntu 12.04下源代码安装MySQL5.6以及Python-MySQLdb http://www.linuxidc.com/Linux/2013-08/89270.htm

MySQL-5.5.38通用二进制安装 http://www.linuxidc.com/Linux/2014-07/104509.htm

--------------------------------------分割线 --------------------------------------

本文永久更新链接地址:http://www.linuxidc.com/Linux/2015-01/112583.htm

linux
相关资讯       CentOS安装MySQL 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款