详细讲解Linux环境下MySQL 5.1安装步骤
|
源代码网整理以下Linux环境下MySQL5.1安装步骤: 源代码网整理以下1、下载MySQL免安装版/二进制版软件(不用编译) 源代码网整理以下文件格式:MYSQL-VERSION-OS.tar.gz 源代码网整理以下2、创建MySQL组,建立MySQL用户并加入到mysql组中 源代码网整理以下(不同版本的Unix中,groupadd和useradd的语法可能会稍有不同。) 源代码网整理以下#groupadd mysql 源代码网整理以下#useradd -g mysql mysql 源代码网整理以下3、进入目录/usr/local,解压缩免安装版,并在此目录中建立名为mysql的软链接 源代码网整理以下#cd /usr/local 源代码网整理以下#gunzip < /path/to/MYSQL-VERSION-OS.tar.gz | tar xvf - 源代码网整理以下(该命令会在本目录下创建一个名为MYSQL-VERSION-OS的新目录。) 源代码网整理以下(使用GNU tar,则不再需要gunzip。你可以直接用下面的命令来解包和提取分发: 源代码网整理以下#> tar zxvf /path/to/mysql-VERSION-OS.tar.gz) 源代码网整理以下#ln -s MYSQL-VERSION-OS mysql 源代码网整理以下4、添加MySQL配置文件 源代码网整理以下如果你想要设置一个选项文件,使用support-files目录中的一个作为模板。在这个目录中有4个模板文件,是根据不同机器的内存定制的。 源代码网整理以下#cp support-files/my-medium.cnf /etc/my.cnf 源代码网整理以下(可能你需要用root用户运行这些命令。) 源代码网整理以下5、设定目录访问权限,用mysql_install_db创建MySQL授权表初始化,并设置mysql,root帐号访问权限 源代码网整理以下#cd mysql 源代码网整理以下#chown -R mysql . 源代码网整理以下#chgrp -R mysql . 源代码网整理以下#scripts/mysql_install_db –user=mysql 源代码网整理以下#chown -R root . 源代码网整理以下#chown -R mysql data 源代码网整理以下(注意以上命令中的" . "符号不能少。) 源代码网整理以下6、运行MySQL 源代码网整理以下#bin/mysqld_safe –user=mysql & 源代码网整理以下(如果没有问题的话,应该会出现类似这样的提示: 源代码网整理以下[1] 42264 源代码网整理以下# Starting mysqld daemon with databases from /usr/local/mysql/var 源代码网整理以下如果出现 mysql ended这样的语句,表示Mysql没有正常启动,你可以到log中查找问题,Log文件的通常在/etc/my.cnf中配置。 源代码网整理以下大多数问题是权限设置不正确引起的。 ) 源代码网整理以下7、设置root密码。默认安装密码为空,为了安全你需要修改密码 源代码网整理以下#/usr/local/mysql/bin/mysqladmin -uroot password yourpassword 源代码网整理以下8、拷贝编译目录的一个脚本,设置开机自动启动 源代码网整理以下#cp support-files/mysql.server /etc/rc.d/init.d/mysqld 源代码网整理以下#chmod 700 /etc/init.d/mysqld 源代码网整理以下#chkconfig –add mysqld 源代码网整理以下#chkconfig –level 345 mysqld on 源代码网整理以下9、启动mysqld服务 源代码网整理以下#service mysqld start 源代码网整理以下10、查看3306端口是否打开。要注意在防火墙中开放该端口 源代码网整理以下#netstat -atln 源代码网整理以下免安装版/二进制版安装基本命令概述: 源代码网整理以下shell> groupadd mysql 源代码网整理以下shell> useradd -g mysql mysql 源代码网整理以下shell> cd /usr/local 源代码网整理以下shell> gunzip < /PATH/TO/MYSQL-VERSION-OS.tar.gz | tar xvf - 源代码网整理以下shell> ln -s FULL-PATH-TO-MYSQL-VERSION-OS mysql 源代码网整理以下shell> cd mysql 源代码网整理以下shell> chown -R mysql . 源代码网整理以下shell> chgrp -R mysql . 源代码网整理以下shell> scripts/mysql_install_db –user=mysql 源代码网整理以下shell> chown -R root . 源代码网整理以下shell> chown -R mysql data 源代码网整理以下shell> bin/mysqld_safe –user=mysql & 源代码网供稿. |
