1:下载二进制mysql-5.5.32-linux2.6-x86_64.tar.gz包
wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.32-linux2.6-x86_64.tar.gz
2:解压
tar zxvf mysql-5.5.32-linux2.6-x86_64.tar.gz
3:移动到指定目录
mv mysql-5.5.32-linux2.6-x86_64 /application/
4:创建软链接
ln -s /application/mysql-5.5.32-linux2.6-x86_64/ /application/mysql
5:创建mysql用户
useradd mysql -s /sbin/nologin -M
6:初始化mysql
/application/mysql/scripts/mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql
7:对mysql目录进行授权
chown -R mysql.mysql /application/mysql/
8:拷贝配置文件到/etc/下
cp /application/mysql/support-files/my-small.cnf /etc/my.cnf
9:替换默认启动脚本中mysql所在的目录为安装目录
sed -i ‘s#/usr/local/mysql#/application/mysql#g‘ /application/mysql/bin/mysqld_safe
10:启动mysql
/application/mysql/bin/mysqld_safe &
11:拷贝mysql的命令到/usr/local/sbin/
cp /application/mysql/bin/* /usr/local/sbin/
12:添加mysql为守护进程
cp /application/mysql/support-files/mysql.server /etc/init.d/mysqld
sed -i ‘s#/usr/local/mysql#/application/mysql#g‘ /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
13: /etc/init.d/mysqld
Usage: mysqld {start|stop|restart|reload|force-reload|status} [ MySQL server options ]
14:退出mysql回到命令行,创建mysql的密码
mysqladmin -uroot password "123456"
更改密码mysqladmin -uroot -p123456 password "qwer1234"