①解压MySql安装包
进入到该安装包的保存路径后,通过下面的命令进行解压(解压位置: ../bulid/)
tar zxvf mysql-5.1.53.tar.gz -C ../bulid/
②编译
进入到解压后的文件夹下
安装mysql前需要安装一些linux系统软件
aptitude install lib64ncurses5-dev OR libncurses5-dev
aptitude install g++
aptitude install automake
aptitude install autoconf2.13
autoreconf --force --install
aclocal; autoheader
libtoolize --automake --force
automake --force --add-missing; autoconf
编译MySql,安装到/usr/local/mysql-5.1.53
./configure '--prefix=/usr/local/mysql-5.1.53' '--with-mysqld-user=mysql' '--with-extra-charsets=all' '--with-named-curses-libs=/lib/libncurses.so.5' '--enable-assembler' '--with-charset=utf8'
make
③安装
make install
④添加权限
groupadd mysql
useradd mysql -g mysql
./scripts/mysql_install_db --user=mysql
注:
mysql_install_db出现FATAL ERROR: Could not find mysqld错误时,
因为/etc/mysql/下出现了个my.cnf
解决方法:
mv /etc/mysql/my.cnf /etc/mysql/my.cnf.bak
cp support-files/my-medium.cnf /etc/cnf
cd /usr/local/mysql-5.1.53/
chown -R root .
chown -R mysql var
chown -R mysql var/.
chown -R mysql var/mysql/.
chgrp -R mysql .
⑤运行并查看是否安装成功
/usr/local/mysql-5.1.39/bin/mysqld_safe --user=mysql &
lsof -i:3306 --查看3306端口是否是mysql在运行。
./bin/mysql -root
exit --退出mysql
⑥修改mysql密码
/usr/local/mysql-5.1.53/bin/mysqladmin -uroot password root
./bin/mysql -uroot -p --再次登录
root --密码
⑦添加别人能够访问的权限
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
use mysql;
mysql> select User,host from user;
+------+-----------+
| User | host |
+------+-----------+
| root | % |
| root | 127.0.0.1 |
| | camp |
| root | camp |
| | localhost |
| root | localhost |
+------+-----------+
6 rows in set (0.00 sec)
注:编译或安装过程中可能会因缺少某些文件而导致error
则根据error提示的信息,先安装缺少的文件再重新编译安装
error例;
checking for termcap functions library... configure: error: No curses/termcap library found
安装install lib64ncurses5-dev后则此错误就可避免
通过命令 「aptitude search 查找内容」查找相应的文件