mysql5.5以上使用cmake
下载source code 下 mysql-5.5.**.tar.gz
一、一些依赖
1.安装make编译器
下载地址: http://www.gnu.org/software/make/
- tar zxvf make-3.82.tar.gz
- cd make-3.82
- ./configure
- make
- make install
2.安装bison
下载地址:http://www.gnu.org/software/bison/
- tar zxvf bison-2.5.tar.gz
- cd bison-2.5
- ./configure
- make
- make install
3.安装gcc-c++
下载地址:http://www.gnu.org/software/gcc/
- tar zxvf gcc-c++-4.4.4.tar.gz
- cd gcc-c++-4.4.4
- ./configure
- make
- make install
4.安装cmake
- tar zxvf cmake-2.8.4.tar.gz
- cd cmake-2.8.4
- ./configure
- make
- make install
5.安装ncurses 和 ncurses-deve
下载地址:http://www.gnu.org/software/ncurses/
- tar zxvf ncurses-5.8.tar.gz
- cd ncurses-5.8
- ./configure
- make
- make install
6
yum install ncurses-devel
二、安装
1,解压并安装MySQL
cmake出错之后需要删除 CMakeCache.txt 才能再执行
tar zxvf mysql-5.5.13.tar.gz
cd mysql-5.5.13
cmake ./ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DINSTALL_DATADIR=/usr/local/mysql/data
make
make install
2,创建数据库
//添加用户和用户组
groupadd mysql
useradd -r -g mysql mysql
//创建数据库
cd /usr/local/mysql
chown -R mysql .
chgrp -R mysql .
scripts/mysql_install_db --user=mysql
//之后必须保证data目录是mysql用户、组
3,启动mysql:
cp support-files/my-medium.cnf /etc/my.cnf
bin/mysqld_safe --user=mysql &
#启动mysql,看是否成功
netstat -tnl|grep 3306
或者加到服务,开机自动启动
#将mysql的启动服务添加到系统服务中
cp support-files/mysql.server /etc/init.d/mysql.server
#现在可以使用下面的命令启动mysql
service mysql.server start
#停止mysql服务
service mysql.server stop
#重启mysql服务
service mysql.server restart
开机自动启动
chkconfig --add mysql.server
4,安装mysql-client.5.5.33
cat /proc/version 根据版本号到官网找到对应的client rpm
三,问题
1报错:Starting MySQL. ERROR! The server quit without updating PID file (/usr/local/mysql/data/localhost.localdomain.pid).
data目录必须是mysql用户
2输入mysql,报错:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@localhost /]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
#mysql命令要通过/var/lib/mysql/mysql.sock 进入,查看有没有这个文件。
[root@localhost mysql]# find / -name mysql.sock
/tmp/mysql.sock
#发现没有, 而是在 /tmp/下
[root@localhost /]# ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock
#加个软连接
3远程连接
赋予权限: 格式:grant 权限 on 数据库名.表名 to 用户@登录主机 identified by "用户密码"; grant all on *.* to root@192.168.1.12 identified by "123456";
4无法连接
解决Mysql无法远程连接的问题
1、Mysql的端口是否正确
通过netstat -ntlp |grep 3306
2、查看/etc/mysql/my.cnf中,skip-networking 需要注掉
3、查看iptables是否停掉,系统启动时不启动iptables服务
关闭iptables chkconfig iptables off
chkconfig --del iptables
5,下错安装包:
CMake Error: The source directory "/usr/local/package/mysql-5.5.39-linux2.6-i686" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.
42万+

被折叠的 条评论
为什么被折叠?



