Mysql-5.1.46源代码安装方法
# chmod 755 mysql-5.1.46.tar.gz # tar -zxvf mysql-5.1.46.tar.gz -C /usr/src/ # cd /usr/src/mysql-5.1.46 # ./configure --prefix=/usr/local/mysql-5.1.46 --localstatedir=/usr/local/mysql-5.1.46/data --sysconfdir=/usr/local/mysql-5.1.46/etc/ --with-charset=gbk --with-extra-charsets=all --with-big-tables --without-debug --with-plugins=max ( --with-unix-socket-path=/tmp/mysql3307.sock --with-tcp-port=3307 //安装多个数据库Mysql时需要加上此选项) # make # make install # groupadd mysql # useradd mysql -g mysql # mkdir /usr/local/mysql-5.1.46/etc/ # mkdir /usr/local/mysql-5.1.46/logs/ # chowm mysql:mysql /usr/local/mysql-5.1.46/etc/ # chowm mysql:mysql /usr/local/mysql-5.1.46/logs
# cp /usr/local/mysql-5.1.46/share/mysql/my-large.cnf /usr/local/mysql-5.1.46/etc/my.cnf //注意默认使用/etc/my.cnf ,建议删除系统自带的my.cnf, 或者修改Mysql启动脚本中my.cnf 路径. # cd /usr/local/mysql-5.1.46/bin # ./mysql_install_db --user=mysql # cd /usr/local/mysql-5.1.46/ # chown -R root . # chown -R mysql data # chgrp -R mysql . # /usr/local/mysql-5.1.46/bin/mysqld_safe --user=mysql & # netstat -tnl |grep 3306 # /usr/local/mysql-5.1.46/bin/mysql -uroot -p # show databases; # /usr/local/mysql-5.1.46/bin/mysqladmin -uroot password 8732 # cp /usr/local/mysql-5.1.46/share/mysql/mysql.server /etc/init.d/mysqld # cd /etc/init.d/ # chmod +x mysqld # chkconfig mysqld # chkconfig --add mysqld # chkconfig --level 345 mysqld on # service mysqld stop # cp /usr/local/mysql/bin/* /usr/bin/ 为了安全,建议数据库的数据文件通过符号链接,(或在安装时就指定到其它分区) # su - mysql 以mysql用户的身分创建data的符号连接,data --->/db/data #ln -s /db/data data 然后,退出mysql用户 以root用户的身分将/home/mysql/data符号移动到 /usr/local/mysql/ #mv /home/mysql/data /usr/local/mysql/ #
设置日志文件配置.修改:my.cnf
[msyqld]
log-error=/usr/local/mysql-5.1.46/logs/error.log //Mysql 错误日志 log-slow-admin-statements long_query_time = 3 //延时SQL时间设置默认为秒 log-queries-not-using-indexes slow_query_log slow_query_log_file=/usr/local/mysql-5.1.46/logs/slow.log //延时SQL日志目录
general_log general_log_file=/usr/local/mysql-5.1.46/logs/mysql.log //执行的SQL语句,生产环境建议关闭此选项.
用户管理:
mysql>grant select,insert,update,create,delete,drop,index,alter,references,create temporary tables,lock tables on aa. * to aa identified by "123456";
mysql> flush privileges;
到此mysql-5.1.46 安装完成,,
|
阅读(991) | 评论(0) | 转发(0) |