LAMP1 - Mysql安装
注:此版本为绿色软件版本,不需要编译安装
mysql-standard-5.0.27-linux-i686-glibc23.tar.gz 下载地址:
http://downloads.mysql.com/archives.php?p=mysql-5.0&v=5.0.27
中的 Linux (Standard, glibc-2.3, x86) (21 Oct 2006, 28.7M) 这个文件
--------------------------------------------------------------------------------------------
检查是否 安装过 (Linux 下安装软件都要检查是否安装过)
rpm -qa|grep mysql //rpm 包检查
ps -ef|grep mysql //tar.gz 包检查
删除 : rpm -e mysql -nodeps // -nodeps 强制性删除
============================================================
开始安装:
一.
[root@localhost qi]# tar -zxvf mysql-standard-5.0.27-linux-i686-glibc23.tar.gz //在自己的家下解压
cp -Rp /home/qi/mysql-standard-5.0.27-linux-i686-glibc23 /usr/local/mysql //复制到安装路径
二.
groupadd mysql //给mysql创建用户和用户组
useradd -g mysql mysql
添加完之后,查看 ls -l /var/spool/mail
[root@localhost local]# ls -l /var/spool/mail
总用量 16
-rw-rw---- 1 mysql mail 0 11月 23 12:15 mysql //这条记录是用户和组的记录,跟mysql数据库安装没关系,所以要重装mysql数据库的时候,这个不用跟着删除
-rw------- 1 root root 3682 11月 19 15:54 root
-rw-rw---- 1 xuezhiqi mail 0 11月 18 02:08 xuezhiqi
三.
安装
[root@localhost qi]# cd /usr/local/mysql //进入到安装路径
[root@localhost mysql]# scripts/mysql_install_db --user=mysql //以mysql的身份安装
Installing all prepared tables
Fill help tables
To start mysqld at boot time you have to copy support-files/mysql.server
to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
See the manual for more instructions.
You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe &
You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:
cd sql-bench ; perl run-all-tests
Please report any problems with the ./bin/mysqlbug script!
The latest information about MySQL is available on the web at
http://www.mysql.com
四.
修改mysql拥有者和所属组
[root@localhost mysql]# chown -R root . [root@localhost mysql]# chown -R mysql data [root@localhost mysql]# chgrp -R mysql .
[root@localhost mysql]# ls -l
总用量 168
drwxr-xr-x 2 root mysql 4096 2006-10-21 bin
-rwxr-xr-x 1 root mysql 801 2006-10-21 configure
-rw-r--r-- 1 root mysql 19071 2006-10-20 COPYING
drwxr-x--- 4 mysql mysql 4096 11月 22 17:22 data
drwxr-xr-x 2 root mysql 4096 2006-10-21 docs
-rw-r--r-- 1 root mysql 5806 2006-10-21 EXCEPTIONS-CLIENT
drwxr-xr-x 2 root mysql 4096 2006-10-21 include
-rw-r--r-- 1 root mysql 7752 2006-10-21 INSTALL-BINARY
drwxr-xr-x 2 root mysql 4096 2006-10-21 lib
drwxr-xr-x 4 root mysql 4096 2006-10-21 man
drwxr-xr-x 14 root mysql 4096 2006-10-21 mysql-standard-5.0.27-linux-i686-glibc23
drwxr-xr-x 7 root mysql 4096 2006-10-21 mysql-test
-rw-r--r-- 1 root mysql 1380 2006-10-20 README
drwxr-xr-x 2 root mysql 4096 2006-10-21 scripts
drwxr-xr-x 3 root mysql 4096 2006-10-21 share
drwxr-xr-x 5 root mysql 4096 2006-10-21 sql-bench
drwxr-xr-x 2 root mysql 4096 2006-10-21 support-files
drwxr-xr-x 2 root mysql 4096 2006-10-21 tests
五.
启用mysql进程
[root@localhost mysql]# bin/mysqld_safe --user=mysql &
注: --user=mysql : 做事什么事都希望以mysql的身份执行;&:应到后台执行
[2] 8249
[1] Exit 127 bin/mysql_safe --user=mysql
[root@localhost mysql]# Starting mysqld daemon with databases from /usr/local/mysql/data
六.登陆
[root@localhost mysql]# bin/mysql -u root
mysql>
===================================================================================
编译安装 :
--with-extra-charsets=all 是用来支持所有的字符集
=====================================================================================
重装之后出现的问题:
1.在重装前要记得 kill 掉 mysql 的进程,避免占用端口; 或者停止mysql服务
端口被占用 : 查看
lsof -i:3306
解决 :
方法1. kill pid号
方法2.停止mysql服务:
[root@localhost mysql]# support-files/mysql.server
Usage: support-files/mysql.server {start|stop|restart|reload} [ MySQL server options ]
2.重装后启动服务的时候提示 :STOPPING server from pid file /usr/local/mysql/data/localhost.localdomain.pid
查看日记:
cat data/localhost.localdomain.err
错误内容:(原因:有人说是 1.原因是重装的时候数据目录不一致导致; 2.因为在进行初始化数据库权限表的那一步的时候默认创建的权限表在默认目录/usr/local/mysql/var下面,这就造成了,上面的错误无法找到权限表)
Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
解决方法:
scripts/mysql_install_db --usrer=mysql --datadir=/usr/local/mysql/data/
错误日记二.
13:14:27 [ERROR] Can't start server: Bind on TCP/IP port: Address already in use
121123 13:14:27 [ERROR] Do you already have another mysqld server running on port: 3306 ?
121123 13:14:27 [ERROR] Aborting