mysql安装指南
本文详细介绍在linux下如何安装mysql。mysql的版本是预编译好的二进制包,非rpm。
- 下载mysql
下载地址:http://dev.mysql.com/downloads/mysql/5.1.html,在Select Platform中选择Linux-generic,在列表中找到Generic Linux (glibc 2.3) (x86, 32-bit), Compressed TAR Archive,如果是64位系统,选择对应的64位的包。
- 增加mysql用户和用户组
groupadd mysql useradd -g mysql mysql
- 检查系统是否存在老版本的mysql
在centos下通过rpm -qa | grep mysql 查找一把,如果存在就通过 rpm -e mysql rpm名来卸载。
- 安装配置
1、cd /usr/local 2、tar -zxvf /pathto/mysql-5.1.58-linux-i686-glibc23.tar.gz 3、ln -s mysql-5.1.58-linux-i686-glibc23 mysql 4、cp /usr/local/mysql/support-files/my-large.cnf /etc/my.cnf 5、vi /etc/my.cnf [mysqld] port = 3306 socket = /tmp/mysql.sock #增加的项 datadir = /var/lib/mysql/data
# Uncomment the following if you are using InnoDB tables innodb_data_home_dir = /var/lib/mysql/data innodb_data_file_path = ibdata1:2000M:autoextend innodb_log_group_home_dir = /var/lib/mysql/data/ # You can set .._buffer_pool_size up to 50 - 80 % # of RAM but beware of setting memory usage too high innodb_buffer_pool_size = 256M innodb_additional_mem_pool_size = 20M # Set .._log_file_size to 25 % of buffer pool size innodb_log_file_size = 64M innodb_log_buffer_size = 8M innodb_flush_log_at_trx_commit = 1 innodb_lock_wait_timeout = 50
6、mkdir -p /var/lib/mysql/data
7.1、cd /usr/local/mysql/
7.2、./scripts/mysql_install_db
如果出现错误,试着用 /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/var/lib/mysql/data
8、chown -R mysql:mysql /var/lib/mysql
9、cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
10、/etc/init.d/mysqld start
在5.1.60按照此方法安装后,启动时报错,从错误日志发现mysqld用的数据目录还是默认的/usr/local/mysql/data/,没有使用my.cnf中设置的,解决办法可以修改/etc/init.d/mysqld,找到datadir并把它设置为自己的数据目录,另外在这个版本中似乎已经不支持在my.cnf中设置datadir了,使用mysqld_safe启动时候出现过警告,The data directory is a deprecated location for my.cnf, please move it to …。
欢迎转载,转载请注明文章出处,谢谢!