发布时间:2014-09-05 17:40:52作者:知识屋
这几天在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 –R 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服务
[plain] view plaincopyprint?01.[root@local ~]# service mysql start
[root@local ~]# service mysql start
测试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)
linux一键安装web环境全攻略 在linux系统中怎么一键安装web环境方法
Linux网络基本网络配置方法介绍 如何配置Linux系统的网络方法
Linux下DNS服务器搭建详解 Linux下搭建DNS服务器和配置文件
对Linux进行详细的性能监控的方法 Linux 系统性能监控命令详解
linux系统root密码忘了怎么办 linux忘记root密码后找回密码的方法
Linux基本命令有哪些 Linux系统常用操作命令有哪些
Linux必学的网络操作命令 linux网络操作相关命令汇总
linux系统从入侵到提权的详细过程 linux入侵提权服务器方法技巧
linux系统怎么用命令切换用户登录 Linux切换用户的命令是什么
在linux中添加普通新用户登录 如何在Linux中添加一个新的用户
2012-07-10
CentOS 6.3安装(详细图解教程)
Linux怎么查看网卡驱动?Linux下查看网卡的驱动程序
centos修改主机名命令
Ubuntu或UbuntuKyKin14.04Unity桌面风格与Gnome桌面风格的切换
FEDORA 17中设置TIGERVNC远程访问
StartOS 5.0相关介绍,新型的Linux系统!
解决vSphere Client登录linux版vCenter失败
LINUX最新提权 Exploits Linux Kernel <= 2.6.37
nginx在网站中的7层转发功能