Centos 5.x 安装 mysql5.x

原文:http://www.weiruoyu.cn/?p=622


1、安装编译环境

[shell]yum install gcc gcc-c++ autoconf automake ncurses-devel make chkconfig[/shell]

2、下载,解压缩

[shell]
wget http://mysql.mirror.tw/Downloads/MySQL-5.1/mysql-5.1.45.tar.gz
tar -xzvf mysql-5.1.45.tar.gz
[/shell]

3、编译

[shell]

 
 
  1. CFLAGS="-O3"CXX=gccCXXFLAGS="-O3 -felide-constructors -fno-exceptions -fno-rtti"

  2. ./configure -prefix=/usr/local/mysql -enable-assembler -with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock -with-mysqld-ldflags=-all-static -with-client-ldflags=-all-static -with-extra-charsets=gb2312,gbk,utf8,latin1 -without-debug -with-charset=utf8-with-collation=utf8_general_ci -with-pthread -enable-static -enable-thread-safe-client


[/shell]

完成后会提示"Thank you for choosing MySQL!"

[shell]make[/shell]

最后会提示“make all win…”

[shell]make install[/shell]

4、添加用户,安装数据库

[shell]
useradd mysql
passwd mysql #设置密码,例如mysql123

cd /usr/local/mysql/
chown -R mysql:mysql ./

#安装数据库,添加默认mysql配置
./bin/mysql_install_db �Cuser=mysql
cp share/mysql/my-medium.cnf /etc/my.cnf
[/shell]

4、配置、开机自启动

[shell]
#经过上述配置后,mysql应该就可以正常启动了
./bin/mysqld_safe �Cuser=mysql &

#下面我们来设置开机启动mysql
kill掉上述测试进程(一般是两个mysqld_safe是一个shell,它来启动mysqld的daemon)
cp share/mysql/mysql.server /etc/init.d/mysqld
chkconfig �Cadd mysqld
chkconfig �Clevel 2345 mysqld on
#之后可以用service mysqld start启动,开机会自动启动
[/shell]

5、my.cnf参数调优

[shell]vim /etc/my.cnf[/shell]

6、安全配置

[shell]
#设置root密码
mysqladmin -u root password ‘new-password’

#删除test数据库、匿名帐户
mysql -u root -p
mysql> DROP DATABASE test; [删除test数据库]
mysql> DELETE FROM mysql.user WHERE user = ”; [删除匿名帐户]
mysql> FLUSH PRIVILEGES; [重载权限]
[/shell]

7、小内存优化

只要不开InnoDB,my-medium.cnf 一般可以保证很小的内存占用和较高的性能了,具体的MySQL内存优化待续。


8.添加软连接。mysql直接运行

把MYSQLPATH/bin/mysql映射到/usr/local/bin目录下:

cd /usr/local/bin
ln -fs /MYSQLPATH/bin/mysql mysql

还有其它常用命令mysqladmin, mysqldump等
MYSQLPATH是你的mysql的安装位置
否则会报错
运行mysql提示command not found.



http://www.coder4.com/archives/632
http://hi.baidu.com/iworkiwin/blog/item/e1b81c221c7d784393580740.html

http://www.junguo.info/2010/11/02/%E8%BF%90%E8%A1%8Cmysql%E6%8F%90%E7%A4%BAcommand-not-found/

你可能感兴趣的:(mysql,权限,用户,添加)