Centos成功安装mysql-5.5.37

摘自http://www.2cto.com/os/201404/296364.html(原文请关注)


这几天在centos下装mysql,这里记录一下安装的过程,方便以后查阅

Mysql5.5.37安装需要cmake,5.6版本开始都需要cmake来编译,5.5以后的版本应该也要装这个。

安装cmake

[plain] view plaincopyprint?01.[[email protected] ~]# wget http://www.cmake.org/files/v2.8/cmake-2.8.12.2.tar.gz

02.[[email protected] ~]# tar xvf cmake-2.8.12.2.tar.gz

03.[[email protected] ~]# cd cmake-2.8.12.2

04.[[email protected] cmake-2.8.12.2]#./bootstrap

05.[[email protected] cmake-2.8.12.2]# make

06.[[email protected] cmake-2.8.12.2]# make install

[[email protected] ~]# wget http://www.cmake.org/files/v2.8/cmake-2.8.12.2.tar.gz

[[email protected] ~]# tar xvf cmake-2.8.12.2.tar.gz

[[email protected] ~]# cd cmake-2.8.12.2

[[email protected] cmake-2.8.12.2]#./bootstrap

[[email protected] cmake-2.8.12.2]# make

[[email protected] cmake-2.8.12.2]# make install 安装mysql

[plain] view plaincopyprint?01.[[email protected] ~]# wget http://cdn.mysql.com/Downloads/MySQL-5.5/mysql-5.5.37.tar.gz

02.[[email protected] ~]# tar xvf mysql-5.5.37.tar.gz

03.[[email protected] ~]# cd mysql-5.5.37

04.[[email protected] mysql-5.5.37]# cmake ./

[[email protected] ~]# wget http://cdn.mysql.com/Downloads/MySQL-5.5/mysql-5.5.37.tar.gz

[[email protected] ~]# tar xvf mysql-5.5.37.tar.gz

[[email protected] ~]# cd mysql-5.5.37

[[email protected] mysql-5.5.37]# cmake ./

可能还会报这个错,没有就跳过

[plain] view plaincopyprint?01.CMake Error at cmake/readline.cmake:83(MESSAGE):

02.Curses library not found.  Pleaseinstall appropriate package,

03.remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name islibncurses5-dev, on Redhat and derivates it is ncurses-devel.

04.Call Stack (most recent call first):

05. cmake/readline.cmake:127 (FIND_CURSES)

06. cmake/readline.cmake:217 (MYSQL_USE_BUNDLED_LIBEDIT)

07. CMakeLists.txt:355 (MYSQL_CHECK_READLINE

08.-- Configuring incomplete, errors occurred!

09.See also "/root/my/mysql-5.5.37/CMakeFiles/CMakeOutput.log".

10.See also"/root/my/mysql-5.5.37/CMakeFiles/CMakeError.log".

CMake Error at cmake/readline.cmake:83(MESSAGE):

Curses library not found.  Pleaseinstall appropriate package,

remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name islibncurses5-dev, on Redhat and derivates it is ncurses-devel.

Call Stack (most recent call first):

cmake/readline.cmake:127 (FIND_CURSES)

cmake/readline.cmake:217 (MYSQL_USE_BUNDLED_LIBEDIT)

CMakeLists.txt:355 (MYSQL_CHECK_READLINE

-- Configuring incomplete, errors occurred!

See also "/root/my/mysql-5.5.37/CMakeFiles/CMakeOutput.log".

See also"/root/my/mysql-5.5.37/CMakeFiles/CMakeError.log".

说明centos系统没有ncurses-devel

[plain] view plaincopyprint?01.[[email protected] ~]# wgethttp://invisible-island.net/datafiles/release/ncurses.tar.gz

02.[[email protected] ~]# cd ncurses-5.9

03.[[email protected] ncurses-5.9]#./configure

04.[[email protected] ncurses-5.9]# make

05.[[email protected] ncurses-5.9]# make install

[[email protected] ~]# wgethttp://invisible-island.net/datafiles/release/ncurses.tar.gz

[[email protected] ~]# cd ncurses-5.9

[[email protected] ncurses-5.9]#./configure

[[email protected] ncurses-5.9]# make

[[email protected] ncurses-5.9]# make install

再删除刚才编译生成的 CMakeCache.txt 文件,否则无法进行下一步

[plain] view plaincopyprint?01.[[email protected] mysql-5.5.37]# rm -f CMakeCache.txt

[[email protected] mysql-5.5.37]# rm -f CMakeCache.txt

继续编译mysql

[plain] view plaincopyprint?01.[[email protected] ~]# cmake ./

02.[[email protected] ~]# make

03.[[email protected] ~]# make install

[[email protected] ~]# cmake ./

[[email protected] ~]# make

[[email protected] ~]# make install

这样,mysql默认将成功安装到/usr/local/mysql

创建mysql用户组

[plain] view plaincopyprint?01.[[email protected] ~]# groupadd mysql

02.[[email protected] ~]# useradd –r –g mysql mysql

03.[[email protected] ~]# chown –R mysql.mysql /usr/local/mysql

[[email protected] ~]# groupadd mysql

[[email protected] ~]# useradd –r –g mysql mysql

[[email protected] ~]# chown –R mysql.mysql /usr/local/mysql

启动mysql

[plain] view plaincopyprint?01.[[email protected] ~]# /usr/local/mysql/bin/mysqld_safe --user=mysql

[[email protected] ~]# /usr/local/mysql/bin/mysqld_safe --user=mysql

这里可能会发生错误,没有就跳过:

[plain] view plaincopyprint?01.FATAL ERROR: Could not find./bin/my_print_defaults

02.If you compiled from source, you need torun ‘make install‘ to

03.copy the software into the correct locationready for operation.

04.If you are using a binary release, you musteither be at the top

05.level of the extracted archive, or pass the --basedir option

06.pointing to that location.

FATAL ERROR: Could not find./bin/my_print_defaults

If you compiled from source, you need torun ‘make install‘ to

copy the software into the correct locationready for operation.

If you are using a binary release, you musteither be at the top

level of the extracted archive, or pass the --basedir option

pointing to that location.

解决方法:

[plain] view plaincopyprint?01.[[email protected] ~]# /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

[[email protected] ~]# /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

再启动mysql

[plain] view plaincopyprint?01.[[email protected] ~]# /usr/local/mysql/bin/mysqld_safe --user=mysql

[[email protected] ~]# /usr/local/mysql/bin/mysqld_safe --user=mysql

注册mysql服务,开机自动启动

1.设置mysql配置文件到/etc目录

[plain] view plaincopyprint?01.[[email protected] ~]# cp /usr/local/mysql/support-files/my-medium.cnf/etc/my.cnf

[[email protected] ~]# cp /usr/local/mysql/support-files/my-medium.cnf/etc/my.cnf

2.设置mysql开机自启

[plain] view plaincopyprint?01.[[email protected] ~]# cp/usr/local/mysql/support-files/mysql.server /etc/init.d/mysql

02.[[email protected] ~]# chmod +x /etc/init.d/mysql

03.[[email protected] ~]# /sbin/chkconfig --add mysql

[[email protected] ~]# cp/usr/local/mysql/support-files/mysql.server /etc/init.d/mysql

[[email protected] ~]# chmod +x /etc/init.d/mysql

[[email protected] ~]# /sbin/chkconfig --add mysql

3.启动mysql服务

可以添加系统变量:export PATH=/usr/local/mysql/bin/:$PATH

[plain] view plaincopyprint?01.[[email protected] ~]# service mysql start

[[email protected] ~]# service mysql start


如果出现错误Starting MySQL.. ERROR! The server quit without updating PID file (/usr/local/mysql/data/iZ23i33p2ccZ.pid).等


则可查看日志cat /usr/local/mysql/data/iZ23i33p2ccZ.err


执行/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data自动刷新重启下

测试mysql是否安装成功


[plain] view plaincopyprint?01.[[email protected] ~]# /usr/local/mysql/bin/mysql -u root -p

02.Enter password:

03.Welcome to the MySQL monitor.  Commands end with ; or \g.

04.Your MySQL connection id is 1

05.Server version: 5.5.37 Source distribution

06.

07.Copyright (c) 2000, 2014, Oracle and/or itsaffiliates. All rights reserved.

08.

09.Oracle is a registered trademark of OracleCorporation and/or its

10.affiliates. Other names may be trademarksof their respective

11.owners.

12.

13.Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ toclear the current input statement.

14.

15.mysql> show databases;

16.+--------------------+

17.| Database           |

18.+--------------------+

19.| information_schema |

20.| mysql              |

21.| performance_schema |

22.| test               |

23.+--------------------+

24.4 rows in set (0.03 sec)

Centos成功安装mysql-5.5.37

时间: 2024-08-15 01:02:03

Centos成功安装mysql-5.5.37的相关文章

CentOS 7 安装MySQL 5.6遇到问题及解决方案

centos下安装mysql真的没有想象中那么容易,在这里我总结一下遇到的问题 1. ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) 出现这种问题一般是MySQL-server没有安装成功,可以通过yum install MySQL-server-5.6.25-1.el7.x86_64.rpm重新安装 2. Fatal error: Can

在Linux(CentOS)上安装MySql详细记录

前记:  毕业两年了,前两天换了份工作,由以前的传统行业跳到了互联网行业.之前的公司一直在用WinServer2003+Tomcat+SqlServer/Oracle这套部署环境.对于Linux+Tomcat(或其他容器)+Mysql这套之前没用用过.所以利用这周末的我在阿里云上49元搞了个linux(centos 64位)的服务器. 刚开始先装了JDK1.6,安装了Tomcat6.0.这过程中没有遇到太大的问题, 小问题也google一下就解决了.而周六晚上开始安装Mysql,于是到今天下午为

Centos下安装mysql 总结

一.MySQL安装 Centos下安装mysql 请点开:http://www.centoscn.com/CentosServer/sql/2013/0817/1285.html 二.MySQL的几个重要目录 MySQL安装完成后不象SQL Server默认安装在一个目录,它的数据库文件.配置文件和命令文件分别在不同的目录,了解这些目录非常重要,尤其对于Linux的初学者,因为 Linux本身的目录结构就比较复杂,如果搞不清楚MySQL的安装目录那就无从谈起深入学习. 下面就介绍一下这几个目录.

CentOS 6 安装MySQL后的root密码

在CentOS 6 安装MySQL 很简单 yum install mysql-server 安装完成后尝试登录MySQL 却不成功,用空密码和系统root密码都不成 mysql -u root -p 原来,在安装完成后,还需要使用mysql_secure_installation 设置root密码和其他安全设置 shell> mysql_secure_installation

CentOS 7 安装 MySQL 5.7.23

阿里云服务器 CentOS 7 安装 MySQL 5.7.23 . 一.准备工作 1.MySQL 官网下载 MySQL 5.7.23 :mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz 2.检查是否已经安装过 MySQL : $> rpm -qa | grep mysql 如果已经安装过其他版本的 MySQL,使用以下命令卸载:$> rpm -e 已经存在的MySQL全名 3.添加用户组,用专门管理mysql,提高安全 (非必须,可以跳过 ) $> g

在centos上安装mysql

本文依然是用的xftp上传gz文件,然后在xShell上操作的,如果没有安装使用这两个文件的请查阅之前的博客. 1.将下载好的文件用xftp上传到对应的位置. 2.解压文件:tar  -zvxf  mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz 3.在/usr/local文件夹下建立mysql的文件夹 mkdir /usr/local/mysql 4.将解压后的mysql文移动到 /usr/local/mysql下: mv mysql-5.7.28-linu

在centOS 7安装mysql 5.7。

参考官方文档:https://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/ 首先创建一个repo文件 vim /etc/yum.repos.d/mysql-community.repo 然后根据官方文档写入: 比如在centOS 7安装mysql 5.7 [mysql57-community] name=MySQL 5.7 Community Server baseurl=http://repo.mysql.com/yum/mysql-5.7-

CentOS 7 安装 MySQL Database

CentOS 7 安装 MySQL Database 1. 现在安装包,MySQL的安装包被分成了社区版和企业版,而本文将记录社区版本MySQL安装过程,下载MySQL版本如下: mysql-5.7.16-linux-glibc2.5-x86_64.tar 解压该压缩包后会得到如下两个压缩包(好麻烦...) mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz mysql-test-5.7.16-linux-glibc2.5-x86_64.tar.gz 这里我们只需

centos 编译安装mysql

centos 编译安装mysql,请看附件