一、实验环境
CentOs 6.6
[root@lnmp02 ~]# uname -rs
Linux 2.6.32-504.el6.i686
[root@lnmp02 ~]#
二、实验步骤
1.从网上下载适合的版本,本文采用mysql-5.5.48-linux2.6-i686,下载地址如下:
wget /home/chen/tools http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.48-linux2.6-i686.tar.gz
2.解压并创建软连接文件(解压完相当于编译安装的make && make install完成)
tar xf mysql-5.5.48-linux2.6-i686
mkdir -p /application/mysql
mv mysql-5.5.48-linux2.6-i686 /application/mysql-5.5.48
ln -s /application/mysql-5.5.48/ /application/mysql
3.创建mysql用户,并不创建家目录和不能登录。
useradd mysql -s /sbin/nologin/ -M
4.切换到/application/mysql下,进行初始化数据库。
/application/mysql/scripts/mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data/ --user=mysql
5.授权mysql管理数据库文件
chown -R mysql.mysql /application/mysql/
6.生成mysql配置文件
cp /application/mysql/support-files/mysql-small.cnf /etc/my.cnf
7.配置启动mysql
sed -i 's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysqld_safe
8.配置环境变量(有两种方法,选其中一种)
vi /etc/profile
PATH="/application/mysql/bin:$PATH"
source /etc/profile
或者:cp /application/mysql/bin/* /usr/local/sbin/ 出现如下提示即可:
[root@lnmp02 application]# which mysql
/usr/local/sbin/mysql
9.登录mysql
[root@lnmp02 application]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.48 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
10.设置登录密码和修改密码
/application/mysql//bin/mysqladmin -u root -password 'new-password'
/application/mysql//bin/mysqladmin -u root -h lnmp02 password 'new-password'
mysqladmin -uroot password "密码" ---设置密码
mysqladmin -uroot -pchen password "密码"---修改密码
11.科学的启动方法实现
cp 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
chkconfig mysqld on
chkconfig --list mysqld
完成上诉步骤即可实现二进制安装mysql ^.^
三、实验总结
其实并不难,只要肯用心,送给所有学习中的小伙伴们,加油!!!
本文转自chengong1013 51CTO博客,原文链接:http://blog.51cto.com/purify/1771783,如需转载请自行联系原作者