总结了一下:
首先确定安装ncurses-devel包。
安装方法:
#yum install ncurses-devel
#groupadd mysql
#useradd -g mysql mysql
准备
cmake-2.8.4.tar.gz
mysql-5.5.9.tar.gz
#tar zxf cmake-2.8.4.tar.gz
#cd cmake-2.8.4
#./configure --prefix=/usr/local/cmake
#make
#make install
#tar zxf mysql-5.5.9.tar.gz
#ls
#cd mysql-5.5.9
#cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/var/mysql/data
如果有报错。需要重新cmake,则删掉mysql-5.5.9里面的CMakeCache.txt
#cp support-files/my-medium.cnf /etc/my.cnf
安装完后进入
#cd /usr/local/mysql
#chown mysql.mysql data/ -R
初始化数据库
#./scripts/mysql_install_db --user=mysql --data=/usr/local/mysql/data
#bin/mysqladmin -u root password xxxx
#cp support-files/mysql.server /etc/init.d/mysql
#chmod 755 /etc/init.d/mysql
#chkconfig --level 345 mysql on
#service mysql restart
参考文献:http://lxsym.blog.51cto.com/1364623/307802
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
================================================
安装中的错误
―――
Q:为什么我用PHP连接Mysql时提示“connect fail:Can't connect to local MySQL server through socket '/home/mysql/tmp/mysql.sock' (13)”
A:这是因为PHP没能正常的连接到Mysql套接字,即mysql.sock文件。首先,检查/home/mysql/tmp/目录下是否有mysql.sock这个文件。如果没有,可能是mysql没有正常启动;如果有,可能是/home/mysql/tmp/这个目录的权限不够,用chmod 755 /home/mysql/tmp可解决此问题。
―――
最近新装好的mysql在进入mysql工具时,总是有错误提示:
# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
或者
# mysql -u root -p password 'newpassword'
Enter password:
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'
现在终于找到解决方法了。本来准备重装的,现在不必了。
方法操作很简单,如下:
# /etc/init.d/mysql stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root' and host='root' or host='localhost';//把空的用户密码都修改成非空的密码就行了。
mysql> FLUSH PRIVILEGES;
mysql> quit # /etc/init.d/mysqld restart
# mysql -uroot -p
Enter password: <输入新设的密码newpassword>
==================================================================================================================
建mysql安装目录
[root@xuhost opt]# mkdir /home/mysql/161 yum install ncurses-devel
创建数据目录
[root@xuhost opt]# mkdir /usr/local/mysql/data/
[root@xuhost opt]# chown mysql.mysql -R home/mysql/data
安装 cmake
[root@xuhost opt]# wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz
[root@xuhost opt]# tar zxvf cmake-2.8.4.tar.gz
[root@xuhost opt]# cd cmake-2.8.4
[root@xuhost cmake-2.8.4]# make install
安装mysql 5.5.9
[root@xuhost opt]# tar zxvf mysql-5.5.9.tar.gz
[root@xuhost opt]# cd mysql-5.5.9
[root@xuhost mysql-5.5.9]# cmake -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr/local/mysql -DCMAKE_USE_RELATIVE_PATHS:BOOL=OFF -DENABLED_PROFILING:BOOL=ON -DENABLE_DEBUG_SYNC:BOOL=OFF -DMYSQL_DATADIR:PATH=/usr/local/mysql/data -DMYSQL_TCP_PORT=3306 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DSYSCONFDIR:PATH=/etc -DWITHOUT_SERVER:BOOL=OFF -DWITH_EMBEDDED_SERVER:BOOL=OFF -DWITH_EXTRA_CHARSETS:STRING=all -DDEFAULT_CHARSET=gbk -DDEFAULT_COLLATION=gbk_general_ci -DWITH_INNOBASE_STORAGE_ENGINE:BOOL=ON -DWITH_LIBEDIT:BOOL=ON -DWITH_READLINE:BOOL=OFF -DWITH_SSL:STRING=no -DWITH_UNIT_TESTS:BOOL=OFF -DWITH_ZLIB:STRING=bundled -DENABLED_LOCAL_INFILE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_EXAMPLE_STORAGE_ENGINE=1
[root@xuhost mysql-5.5.9]# make
[root@xuhost mysql-5.5.9]# make install
复制配置文件
[root@xuhost mysql-5.5.9]# cp support-files/my-medium.cnf /etc/my.cnf
复制启动脚本
[root@xuhost mysql-5.5.9]# cp support-files/mysql.server /etc/init.d/mysqld
[root@xuhost mysql-5.5.9]# chmod 755 /etc/init.d/mysqld
初始化数据库 (进到 安装目录)
[root@xuhost mysql5.5.9]# ./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data
启动数据库
[root@xuhost mysql5.5.9]# /etc/init.d/mysqld start