时间:2021-07-01 10:21:17 帮助过:24人阅读
操作系统CentOS,apache2.2.4,数据库Mysql-5.0.18。使用mysql源码包进行安装,也可以使用mysql二进制包安装或者rpm包安装。
操作系统CentOS,apache2.2.4,,数据库Mysql-5.0.18。使用mysql源码包进行安装,也可以使用mysql二进制包安装或者rpm包安装。
1。增加一个登录用户和群组:
# groupadd mysql
#useradd -g mysql mysql
2。解压mysql-5.0.18.tar.gz到/usr/local/mysql
#tar -zvxf mysql-5.0.18,tar.gz
3。进入mysql-5.0.18目录
#cd mysql-5.0.18
4。运行configure编译mysql源码
#./configure --prefix=/usr/local/mysql/
5。安装mysql到指定的目录
#make;make install
6。把/support-files/my-medium.cnf复制到/etc/下
#cp ./support-files/my-medium.cnf /etc/my.cnf
7。在还没有安装mysql数据库之前,还必须为mysql建立授权表:
#/scripts/mysql_install_db --user=mysql&
注:也可以使用root,但是--user须改为-user
8。修改相应文件的权限(/usr/local/mysql/)
#chown -R root /usr/local/mysql
#chown -R mysql /usr/local/mysql
#chown -R mysql /usr/local/mysql/var
9。启动mysql:(/usr/local/mysql/)
# ./bin/mysqld_safe --user=mysql&
10。安装后mysql数据库的root帐户密码默认为空,可以这样修改:
# /usr/local/mysql/bin/mysqladmin -u root -password 'new-password'
11。把mysql命令加入到环境变量
# echo "export PATH=$PATH:/usr/local/mysql/bin">>/etc/profile
#source /etc/profile //使环境变量生效
#echo $PATH //输出环境变量
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin:/usr/local/mysql/bin
12。开机时启动mysql,把mysql.server放到开机启动的文件中/etc/init.d/mysql:(/usr/local/src/目录下)
#cp ./mysql-5.0.18/support-fiels/mysql.server /etc/init.d/mysql
#chkconfig --add mysql
#chkconfig mysql on
13。登录mysql:(必须把mysql命令加入到环境变量中)
# mysql -u root -p12345
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4 to server version: 5.0.18-log
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
3 rows in set (0.02 sec)