首页 > 代码库 > MYSQL-5.5二进制包安装
MYSQL-5.5二进制包安装
groupadd mysql 添加用户组
useradd mysql -s /sbin/nologin -g mysql -M 添加用户
mv mysql-5.5.54-linux2.6-x86_64.tar.gz /home/ye/software/ 下载软件到软件包
cd /home/ye/software/
tar -xf mysql-5.5.54-linux2.6-x86_64.tar.gz #解压mysql软件
cd mysql-5.5.54-linux2.6-x86_64
mv /home/ye/software/mysql-5.5.54-linux2.6-x86_64/ /application/mysql-5.5.54/ 移动软件包到安装路径内
cd /application/mysql-5.5.54/
ln -s /application/mysql-5.5.54/ /application/mysql #创建软连接
ls -l /application/mysql/support-files/*.cnf
cp /application/mysql/support-files/my-small.cnf /etc/my.cnf 配置配置文件
mkdir -p /application/mysql/data 创建data数据目录
chown -R mysql.mysql /application/mysql/ #修改目录权限
/application/mysql/scripts/mysql_install_db --basedir=/application/mysql -- datadir=/application/mysql/data --user=mysql #初始化mysql
tree /application/mysql/data/ #查看
cp support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld 添加权限
ll /etc/init.d/mysqld
sed -i ‘s#/usr/local/mysql#/application/mysql#g‘ /application/mysql/bin/mysqld_safe /etc/init.d/mysqld #修改配置文件内默认的程序执行路径
/etc/init.d/mysqld start 启动mysql
/application/mysql/bin/mysqld_safe --user=mysql& #另一种方式启动MYSQL
netstat -lntup 查看3306端口是否启动
chkconfig --add mysqld 添加服务
chkconfig mysqld on 设置mysql服务开机默认启动
chkconfig --list mysqld 查看服务状态
echo ‘export PATH=/application/mysql/bin:$PATH‘ >>/etc/profile #更改mysql命令的全局环境变量;另一种方法为把/application/mysql/bin/下面的命令拷贝到已经是全局系统命令的路径/usr/local/sbin下#
source /etc/profile
echo $PATH
mysql 测试登录,默认没有密码
mysqladmin -u root password ‘ye123456‘ 设置root密码
设置完成root密码后需要对MYSQL进行安全配置
注:如遇到提示can‘t crate file ‘/tmp/*‘ 时需要对此目录添加权限chmod -R 1777 /tmp/
MYSQL-5.5二进制包安装