编译mysql5
代码:

./configure \
–prefix=/usr/local/mysql \
–localstatedir=/usr/local/mysql/data \
–with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock \
–with-extra-charsets=all \
–with-charset=utf8 \
–with-client-ldflags=-all-static \
–with-mysqld-ldflags=-all-static \
–with-plugins=all \
–with-pthread \
–enable-thread-safe-client

groupadd mysql
useradd -g mysql mysql

cp support-files/my-medium.cnf /etc/my.cnf

在my.cnf里增加user=mysql
代码:

cd /usr/local/mysql
bin/mysql_install_db –user=mysql
chown -R root . ; chown -R mysql data ;chgrp -R mysql .
bin/mysqld_safe –user=mysql &
mysqladmin -uroot password ‘new-password’

启动mysql:
代码:

/usr/local/mysql/bin/mysqld_safe &

关闭mysql:
代码:

/usr/local/mysql/bin/mysqladmin shutdown

代码:

cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld

可以使用server mysqld restart启动

debian下安装mysql的注意事项–innodb
如果从源代码编译安装mysql,缺省安装时,是没有innodb引擎的.所以,在configure的时候,要加入–with- plugins=all(或者max),这样才会支持innodb.在mysql里可以执行show engines命令来查看当前的mysql服务器所支持的存储引擎.

http://www.mysqlperformanceblog.com/…iled-mysql-51/

多线程支持方面只要注意选择–with-pthread和–enable-thread-safe-client选项就可以了。第一项可以指明使用 posix线程(unix的编译方式可能会有些不一样,因为unix的内核线程工作方式与linux线程工作方式有比较大的区别,尤其freebsd)。

my-small.cnf 最小配置安装,内存<=64M,数据数量最少
my-large.cnf 内存=512M
my-medium.cnf 32M<内存<64M,或者内存有128M,但是数据库与web服务器公用内存
my-huge.cnf 1G<内存<2G,服务器主要运行mysql
my-innodb-heavy-4G.cnf 最大配置安装,内存至少4G

代码:

delete from mysql.user where User=”;
delete from mysql.user where Host=’127.0.0.1′;
delete from mysql.user where Host=’localhost.localdomain’;
update user set Host=’%';

mysql 操作:

查看mysql状态:
/etc/rc.d/init.d/mysqld status

开启mysql
service mysqld start