在进行MySQL安装前,先进行一些准备工作,下载cmake-2.8.8.tar.gz mysql-5.5.32.tar.gz ,至于为什么要下载cmake-2.8.8.tar.gz ,这是因为mysql从5.5之后采用了cmake进行编译.
下载cmake源码包cmake-2.8.8.tar.gz,mv到/usr/local/src目录下,对其进行编译安装
cd /usr/local
tar zxf cmake-2.8.8.tar.gz
cd cmake-2.8.8
./bootstrap
在这里如果没有安装gcc编译器与gcc-c++编译器则会编译报错
因此需要安装这两个编译器
yum -y install gcc
yum -y install gcc-c++
接下来重新编译
./bootstrap
make
make install
cmake –version
当看到打印出的版本cmake version 2.8.8则表示安装成功
接下来安装mysql
#1 创建mysql服务的用户与用户组
groupadd mysql
useradd -g mysql -s/usr/sbin/nologin mysql
#2 创建mysql的安装目录与数据库目录
mkdir -p /usr/local/mysq/
mkdir -p /usr/local/mysql/data
#解压并进入目录
tar -zxf mysql-5.5.32.tar.gz
cd mysql-5.5.32
#3 编译
cmake .
在编译的时候应该会报错
-- Could NOT find Curses
(missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)
CMake Error at cmake/readline.cmake:82 (MESSAGE):
Curses library not found.
Please install appropriate package,
remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.
Call Stack (most recent call first):
cmake/readline.cmake:126 (FIND_CURSES)
cmake/readline.cmake:216 (MYSQL_USE_BUNDLED_LIBEDIT)
CMakeLists.txt:250 (MYSQL_CHECK_READLINE)
-- Configuring incomplete, errors occurred!
缺少Curses包,解决办法:remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.很容易看懂,不解释了...
在CentOS下需要安装ncurses-devel
yum -y install ncurses-devel
#重新编译
cmake .
警告:Warning: Bison executable not found in PATH
yum -y install bison
#再次编译 与安装
cmake .
make && make install
#进入安装目录将程序二进制的所有权改为root 数据目录的所有权改为mysql用户
cd /usr/local/mysql
chown -R root .
chown -R mysql:mysql ./data
# 复制配置文件
cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf
安全启动mysql
/usr/local/mysql/bin/mysqld_safe --usr=mysql &
能开就应该能关
/usr/local/mysql/bin/mysqladmin -u root shutdown -p
默认密码位空
为了能够开机启动服务
将/usr/local/mysql/bin/mysqld_safe --usr=mysql & 添加到/etc/rc.local中
为了方便使用mysql
在/etc/profile中配置环境变量
export MYSQL_HOME=/usr/local/mysql/bin/
PATH=$PATH:$MYSQL_HOME
设置root帐户的密码
mysqladmin -u root password 'yourpassword'
3.1 mysql 数据库端设置
[root@localhost mysql-5.5.11]#/mysql –u root –p //进入数据库
mysql>use mysql
mysql>select user,password,host from user;
mysql>update user set host = '%' where user = 'root';
mysql>grant all privileges on *.* to root@'%' identified by "root";
// 给以root@ ip登录的远程连接赋予权限,
//能够连接数据库。远程无法连接的常见问题原因。
并把远程登录用户的密码设置为root
mysql> flush privileges;
mysql>quit
关闭防火墙
service iptables stop;
接下来客户端就可以连接了