Centos5.8x86_64位操作系统安装5.1.65版本mysql数据库
一、安装mysql数据库之前的准备1.创建一个mysql用户组
1
# groupadd mysql
2.创建MySQL数据库的系统用户,加入到mysql组,不创建mysql家目录,禁止登陆系统
1
# useradd -s /sbin/nologin -g mysql -M mysql
创建一个专门存放mysql压缩包的目录,/taokey/tools
1
# mkdir -p /taokey/tools
把压缩包移到指定目录/taokey/tools下
1
# mv mysql-5.1.65.tar.gz /taokey/tools/
二、编译安装mysql5.1.65数据库
把压缩包移到指定目录/taokey/tools下,进到压缩包所在的目录,进行解压。
# mv mysql-5.1.65.tar.gz /taokey/tools/
# cd /taokey/tools/
# tar -zxvf mysql-5.1.65.tar.gz
# cd mysql-5.1.65
注意:make的时候,会报错:
##编辑configure,删除$RM "$cfgfile"这一行
# vim configure
删除掉 $RM "$cfgfile"//52297行
指定并且编辑mysql安装文件,以及相关参数
1
#./configure --prefix=/application/mysql5.1.65 --with-unix-socket-path=/application/mysql5.1.65/tmp/mysql.sock --localstatedir=/application/mysql5.1.65/data --enable-assembler --enable-thread-safe-client --with-mysqld-user=mysql --with-big-tables --without-debug --with-pthread --enable-assembler --with-extra-charsets=complex --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=partition,innobase --with-plugin-PLUGIN --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static
静态编译生成的mysqld的执行文件
#make
make: Leaving directory `/taokey/tools/mysql-5.1.65/server-tools/instance-manager'
make: Leaving directory `/taokey/tools/mysql-5.1.65/server-tools'
Making all in win
make: Entering directory `/taokey/tools/mysql-5.1.65/win'
make: Nothing to be done for `all'.
make: Leaving directory `/taokey/tools/mysql-5.1.65/win'
没有报错,error之类的错误,就说明make成功了
安装mysql.
#make install
make: Entering directory `/taokey/tools/mysql-5.1.65/win'
make: Entering directory `/taokey/tools/mysql-5.1.65/win'
make: Nothing to be done for `install-exec-am'.
make: Nothing to be done for `install-data-am'.
make: Leaving directory `/taokey/tools/mysql-5.1.65/win'
make: Leaving directory `/taokey/tools/mysql-5.1.65/win'
没有报错,error之类的错误,就说明make install安装成功了
安装成功之后,下边配置mysql,使之可以正常启动
需要拷贝一个mysql的主配置文件,这个是必须拷贝的,我这里复制了一个small
1
#cp support-files/my-small.cnf /etc/my.cnf
做一个软连接/application/mysql5.1.65的软连接,名字为/application/mysql
1
#ln -s /application/mysql5.1.65 /application/mysql
查看下做的软连接是否生效
1
# ls -ld /application/mysql
1
lrwxrwxrwx 1 root root 24 Jan 23 19:48 /application/mysql -> /application/mysql5.1.65
创建一个date目录,用于存放mysql数据
1
#mkdir -p /application/mysql/data
初始化数据库
1
#/application/mysql/bin/mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data/ --user=mysql
拷贝脚本到/etc/init.d/这个目录下,名字为mysqd 方便以后启动
# cp support-files/mysql.server /etc/init.d/mysqld
设置mysqld权限700,出于安全考虑
# chmod 700 /etc/init.d/mysqld
设置mysql属组的权限可以执行/application/mysql/bin/mysql的命令
# chown -R root.mysql /application/mysql/bin/mysql
# echo "/application/mysql/lib/mysql" >> /etc/ld.so.conf
# ldconfig
开启数据库
# /application/mysql/bin/mysqld_safe --user=mysql &
130123 19:43:47 mysqld_safe Starting mysqld daemon with databases from /application/mysql5.1.65/data
# netstat -natp | grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 14003/mysqld
使mysqld脚本有执行权限
# chmod +x /etc/init.d/mysqld
# chkconfig --add mysqld
# chkconfig mysqld on
设置一下mysql数据库的变量
# export PATH=$PATH:/application/mysql/bin
为了永久生效,我们可以让变量追加到etc/profile
# echo "PATH=$PATH:/application/mysql/bin" >>/etc/profile
用source命令,可以使变量马上生效
# source /etc/profile
直接使用mysql就可以登录数据库(无需密码,因为还没有设置密码)
# mysql
Welcome to the MySQL monitor.Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.65 Source distribution
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
成功登录mysql数据库,就是下边的这么标志;
mysql>
退出mysql数据库,当然也可以使用quit退出数据库
mysql> exit
Bye
#
设置mysql的root密码;
# mysqladmin -uroot password '123.com'
用root用户,以及刚刚设置的密码登录数据库
# mysql -uroot -p123.com
Welcome to the MySQL monitor.Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.1.65 Source distribution
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
表示登录数据库成功
mysql>
不在课堂上沉睡,就在酒桌上埋醉。 我妈常说,我们家要是没有电话就不会这么穷。 不在课堂上沉睡,就在酒桌上埋醉。 佛曰,色即是空,空即是色!今晚,偶想空一下 爱——不是想出来的,爱——是做出来的!! 内练一口气,外练一口屁。
页:
[1]