转载源码安装mysql
时间:2010-11-16 来源:hfk_7978
下载页面:http://dev.mysql.com/downloads/mysql/5.0.html#downloads
# cd /mnt/
# tar zxvf mysql-5.0.84.tar.gz
# cd mysql-5.0.84
# ./configure --prefix=/usr/local/mysql --with-charset=gbk --with-extra-charset=all --enable-thread-safe-client --enable-local-infile --with-low-memory
说明:安装到=/usr/local/mysql 下,语言用utf8
通到错误 :configure: error: no acceptable C compiler found in $PATH
说明没安gcc, 现在安:
查看系统是否安装了gcc和安装程序的版本号:
gcc -v
c++ -v
g++ -v
如果没有就用 以下命令安装
#yum install gcc
#yum install gcc-c++
#yum install gcc-gfortran
再次:
# ./configure --prefix=/usr/local/mysql --with-charset=utf8 --with-extra-charset=all --enable-thread-safe-client --enable-local-infile --with-low-memory
还是出错:
checking for termcap functions library... configure: error: No curses/termcap library found
说明要安ncurses
#yum install ncurses-devel
提示安装N个软件,略, 按"y", 完成
再次:
# ./configure --prefix=/usr/local/mysql --with-charset=utf8 --with-extra-charset=all --enable-thread-safe-client --enable-local-infile --with-low-memory
出现:Thank you for choosing MySQL! 说明mysql安装的第一步成功
------------
# make && make install
如果 你的gcc-c++是在configure后安装的,再重新configure一下,可以会以下错误:
error: redeclaration of C++ built-in type ‘bool’
慢长的等待,安好了
-------------
建用户,用户组
# groupadd mysql
# adduser -g mysql mysql
# cp support-files/my-medium.cnf /etc/my.cnf
本例中my-medium.cnf文件在这里: /mnt/mysql-5.0.84/support-files/my-medium.cnf
我们的mysql安装在 /usr/local/mysql/ 里
# chown -R mysql.mysql /usr/local/mysql/
# /usr/local/mysql/bin/mysql_install_db --user=mysql
# chown -R root.root /usr/local/mysql/
# chown -R mysql.mysql /usr/local/mysql/var/
启动一下 ,后面加一个&表示后台运行
# /usr/local/mysql/bin/mysqld_safe --user=mysql &
# netstat -ant 看到3306端品号,说明已启动
加入到开机启动中
# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
给权限
# chmod 755 /etc/rc.d/init.d/mysqld
把mysqld服务加入启动中
# chkconfig --add mysqld
运行级别
# chkconfig --level 345 mysqld on
设置密码
# /usr/local/mysql/bin/mysqladmin -u root password "****"
进入mysql
# /usr/local/mysql/bin/mysql -uroot -p
输入密码,就进入了
看有哪些库 :show databases;
退出:quit
配置mysql 库文件的搜索路径:
# echo "/usr/local/mysql/lib/mysql/" >>/etc.ld.so.conf
# ldconfig 生效
# ldconfig -v 输出一下
添加mysql到系统的环境变量中
# echo "export PATH=$PATH:/usr/local/mysql/bin">>/etc/profile
# source /etc/profile 生效
完成