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

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

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

安装cmake

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

02.[root@local ~]# tar xvf cmake-2.8.12.2.tar.gz 

03.[root@local ~]# cd cmake-2.8.12.2 

04.[root@local cmake-2.8.12.2]#./bootstrap 

05.[root@local cmake-2.8.12.2]# make 

06.[root@local cmake-2.8.12.2]# make install 

[root@local ~]# wget http://www.cmake.org/files/v2.8/cmake-2.8.12.2.tar.gz

[root@local ~]# tar xvf cmake-2.8.12.2.tar.gz

[root@local ~]# cd cmake-2.8.12.2

[root@local cmake-2.8.12.2]#./bootstrap

[root@local cmake-2.8.12.2]# make

[root@local cmake-2.8.12.2]# make install 安装mysql

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

02.[root@local ~]# tar xvf mysql-5.5.37.tar.gz 

03.[root@local ~]# cd mysql-5.5.37 

04.[root@local mysql-5.5.37]# cmake ./ 

[root@local ~]# wget http://cdn.mysql.com/Downloads/MySQL-5.5/mysql-5.5.37.tar.gz

[root@local ~]# tar xvf mysql-5.5.37.tar.gz

[root@local ~]# cd mysql-5.5.37

[root@local 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.[root@local ~]# wgethttp://invisible-island.net/datafiles/release/ncurses.tar.gz 

02.[root@local ~]# cd ncurses-5.9 

03.[root@local ncurses-5.9]#./configure 

04.[root@local ncurses-5.9]# make 

05.[root@local ncurses-5.9]# make install 

[root@local ~]# wgethttp://invisible-island.net/datafiles/release/ncurses.tar.gz

[root@local ~]# cd ncurses-5.9

[root@local ncurses-5.9]#./configure

[root@local ncurses-5.9]# make

[root@local ncurses-5.9]# make install

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

[plain] view plaincopyprint?01.[root@local mysql-5.5.37]# rm -f CMakeCache.txt 

[root@local mysql-5.5.37]# rm -f CMakeCache.txt

继续编译mysql

[plain] view plaincopyprint?01.[root@local ~]# cmake ./ 

02.[root@local ~]# make 

03.[root@local ~]# make install 

[root@local ~]# cmake ./

[root@local ~]# make

[root@local ~]# make install

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

创建mysql用户组

[plain] view plaincopyprint?01.[root@local ~]# groupadd mysql 

02.[root@local ~]# useradd –r –g mysql mysql 

03.[root@local ~]# chown –R mysql.mysql /usr/local/mysql  或者

[root@local ~]# groupadd mysql

[root@local ~]# useradd –r –g mysql mysql

[root@local ~]# chown mysql.mysql /usr/local/mysql

启动mysql

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

[root@local ~]# /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.[root@local ~]# /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data 

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

再启动mysql

[plain] view plaincopyprint?

01.[root@local ~]# /usr/local/mysql/bin/mysqld_safe --user=mysql 

[root@local ~]# /usr/local/mysql/bin/mysqld_safe --user=mysql

注冊mysql服务,开机自己主动启动

1.设置mysql配置文件到/etc文件夹

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

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

2.设置mysql开机自启

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

02.[root@local ~]# chmod +x /etc/init.d/mysql 

03.[root@local ~]# /sbin/chkconfig --add mysql 

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

[root@local ~]# chmod +x /etc/init.d/mysql

[root@local ~]# /sbin/chkconfig --add mysql

3.启动mysql服务

能够加入系统变量:export PATH=/usr/local/mysql/bin/:$PATH

[plain] view plaincopyprint?01.[root@local ~]# 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自己主动刷新重新启动下

我的解决方法是:

可能是/usr/local/mysql/data/rekfan.pid文件没有写的权限

解决方法 :给予权限,运行 “chown -R
mysql:mysql /var/data” “chmod
-R 755 /usr/local/mysql/data”  然后又一次启动mysqld!

參考网址 http://blog.csdn.net/zalion/article/details/9274263

 

測试mysql是否成功安装

[plain] view plaincopyprint?01.[root@local ~]# /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)


假设遇到错误

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

我的解决方法:

创建符号连接:

为mysql.sock添加软连接(相当于windows中的快捷方式)。

ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock

參考网址: http://blog.csdn.net/wyzxg/article/details/4720041

2015-1-24加入例如以下内容,安装完毕后

改动MySQL的root用户的password以及打开远程连接

[root@localhost mysql]# mysql -u root mysql

mysql> use mysql;

mysql> desc user;

mysql> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "root"; //为root加入远程连接的能力

mysql> update user set Password = password('123456') where User='root'; //设置root用户密码

mysql> select Host,User,Password from user where User='root';

mysql> flush privileges;

mysql> exit


假设不行则能够尝试

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

  1. centos 安装配置 mysql

    安装环境:CentOS7 64位 MINI版,安装MySQL5.7 1.配置YUM源 在MySQL官网中下载YUM源rpm安装包:http://dev.mysql.com/downloads/repo ...

  2. Linux CentOS安装配置MySQL数据库

    没什么好说的,直接正面刚吧. 安装mysql数据库 a)下载mysql源安装包:wget http://dev.mysql.com/get/mysql57-community-release-el7- ...

  3. centos安装指定mysql

    mysql下载地址:http://repo.mysql.com/ nginx下载地址 我下载是这个 http://nginx.org/packages/centos/7/noarch/RPMS/ngi ...

  4. CentOS安装配置MySql数据库

    CentOS版本7.2,MySql版本5.7 1.下载MySql安装源     wget https://dev.mysql.com/get/mysql57-community-release-el7 ...

  5. Centos安装成功后配置网络

    一.设置IP地址.网关DNS 说明:CentOS 7.0默认安装好之后是没有自动开启网络连接的! cd /etc/sysconfig/network-scripts/ #进入网络配置文件目录 vi i ...

  6. CentOS安装部署Mysql 5.7

    1,如果没有安装wget,先安装yum -y install wget 2,下载MySQL官方的 Yum Repositorywget http://repo.mysql.com/mysql57-co ...

  7. MySql安装成功后命令行进行必要的配置

    1.1 首次用命令行登录 用zip方式安装成功mysql,并通过net start mysql 命令正常启动mysql服务后,打开dos命令行窗口,输入“mysql -uroot -p”或“mysql ...

  8. (转) Linux(Centos7)yum安装最新mysql

    原文:http://blog.csdn.net/gebitan505/article/details/54613549 环境 CentOS 7.1 (64-bit system) MySQL 5.6. ...

  9. Linux(Centos7)yum安装最新mysql

    环境 CentOS 7.1 (64-bit system) MySQL 5.6.24 CentOS 安装 参考:http://www.waylau.com/centos-7-installation- ...

随机推荐

  1. LinkedHasMap实现原理

    转载:http://blog.csdn.net/luanlouis/article/details/43017071 Map作为键值对Entry<K,V>的的容器,对其内部 键值对Entr ...

  2. ipad ------ 与iPhone的差别

    1. 差异 iPhone是手机,iPad.iPad Mini是平板电脑 iPhone和iPad开发的区别 屏幕的尺寸 \分辨率 UI元素的排布 \设计 键盘 API 屏幕方向的支持 … … 2. iP ...

  3. 30年的Hello world

    30 年的 Hello world 转载自:http://www.admin10000.com/document/2398.html 最近我在7月4日这一天所在的那周休假了.休假期间,我利用大把的时间 ...

  4. Python中类的运算符重载

    这篇文章仅仅是总结性质的,待以后有时间的时候会针对比较难理解的部分补充一些例子. 构造和析构 __init__ __del__ 函数调用 __call__ 打印操作 __str__ __repr__ ...

  5. C语言程序设计做题笔记之C语言基础知识(上)

    C语言是一种功能强大.简洁的计算机语言,通过它可以编写程序,指挥计算机完成指定的任务.我们可以利用C语言创建程序(即一组指令),并让计算机依指令行事.并且C是相当灵活的,用于执行计算机程序能完成的几乎 ...

  6. Cloud Test 在手,宕机时让您不再措手不及

    1月28日,Github 上午 10:04 分宕机了,导致全球各地的用户不能访问.官方回复可能是网络中断引起的,到 10:28 分已经可以正常访问. 对于互联网公司来说,一旦宕机就会措手不及,如何才能 ...

  7. 李洪强漫谈iOS开发[C语言-029] - 关系运算符

  8. 《大数据Spark企业级实战 》

    基本信息 作者: Spark亚太研究院   王家林 丛书名:决胜大数据时代Spark全系列书籍 出版社:电子工业出版社 ISBN:9787121247446 上架时间:2015-1-6 出版日期:20 ...

  9. bzoj1233

    首先这道题有一个很重要的贪心就是 在保证所有干草堆都能参与搭建的前提下,我们尽量使最底层的宽度小,这样搭起来的的干草堆高度一定是最高的 当我们以第i个干草堆为一层,显然最优的情况是找到一个尽可能小的j ...

  10. BZOJ2464: 中山市选[2009]小明的游戏

    2464: 中山市选[2009]小明的游戏 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 280  Solved: 124[Submit][Statu ...