下载:
http://http://dev.mysql.com/downloads/mysql/5.1.html#downloads
配置,编译,安装
1.sh
-
#创建MySQL用户及用户组
-
groupadd mysql
-
useradd -g mysql -s /sbin/nologin mysql
-
-
cp /home/wander/下载/mysql/mysql-5.1.44.tar.gz /usr/local/src
-
cd /usr/local/src
-
tar zxvf mysql-5.1.44.tar.gz
-
chown -R mysql:mysql mysql-5.1.44
-
cd mysql-5.1.44
-
./configure \
-
--prefix=/usr/local/mysql \
-
--localstatedir=/usr/local/mysql/data \
-
--with-unix-socket-path=/usr/local/mysql/data/mysql.sock \
-
--with-plugins=innobase,partition,myisam,heap \
-
--enable-assembler \
-
--with-charset=utf8 \
-
--enable-thread-safe-client \
-
--with-client-ldflags=-all-static \
-
#--with-mysqld-ldflags=-all-static \ 会报错,去掉这一句配置
-
--enable-static=yes \
-
--with-big-tables
-
-
#make
-
#make install
-
ps:
-
如果shell脚本执行出现错误,就手动输入命令
配置:
2.sh
-
#根据应用程序的负载选择对应的配置文件
-
mkdir /usr/local/mysql/etc
-
cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
-
#vi /usr/local/mysql/etc/my.cnf
-
#分配权限
-
chown -R mysql:mysql /usr/local/mysql
安装系统表:
3.sh
-
#安装系统表 这一步很重要,好像没有成功安装系统表的话,MYSQL 就不能启动
-
/usr/local/mysql/bin/mysql_install_db --basedir=/usr/local/mysql --defaults-file=/etc/my.cnf --skip-external-locking --user=mysql
-
-
#启动MySQL
-
/usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/etc/my.cnf --user=mysql &
加入服务启项:
4.sh
-
#加入服务启动项
-
cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysql
-
chmod 700 /etc/init.d/mysqld
-
#chkconfig --add mysqld
mysql 安装成功后,登陆试试
出现错误:
#mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
错误解决:
vim /etc/my.cnf
在[mysqld]条目加入skip-grant-tables
重启mysql
#mysql -u root -p无密码登陆
mysql->use user;
修改密码:
mysql->update user set password=password("新密码") where user="root";
mysql->flush privileges;
mysql->quit;
vim /etc/my.cnf
删除skip-grant-tables
重启mysql
再次登陆就ok了!
ps:
个人建议,安装mysql最后用源码安装,这样可以学到很多东西。虽然会花点时间,但是也是比较值的!
阅读(1431) | 评论(0) | 转发(0) |