标签:mysql
环境: CentOS7
软件:MySQL5.6.26
1 下载MySQL 源码包
wget http://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.2.10/zabbix-2.2.10.tar.gz
2 解压下载的文件到/usr/local目录并修改文件夹名称为mysql
tar -zxvf mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz -C /usr/local mv mysql-5.6.26-linux-glibc2.5-x86_64/ mysql
3创建Mysql用户和用户组
useradd mysql -s /sbin/nologin
4创建Mysql数据库目录并赋予权限给Mysql用户
mkdir -p /data/mysql chown -R mysql:mysql /data/mysql chown -R mysql:mysql /usr/local/mysql
5进入/usr/local/mysql目录 初始化mysql
./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
6 备份系统自带的my.cnf文件,然后把Mysql解压目录中默认配置文件移过去
mv /etc/my.cnf /etc/my.cnf.bak cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
7修改my.cnf文件
datadir=/data/mysql port=3306 socket=/tmp/mysql.sock
8复制解压目录下面的mysql.server文件到/etc/init.d/mysqld
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld chmod 755 /etc/init.d/mysqld vi /etc/init.d/mysqld datadir=/data/mysql #修改数据库目录文件
9 启动mysql服务
service mysqld start Usage: mysqld {start|stop|restart|reload|force-reload|status} [ MySQL server options ]
10 配置mysql的环境变量
echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile source /etc/profile
11 登录mysql
[root@localhost ~]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.6.26 MySQL Community Server (GPL) Copyright (c) 2000, 2015, 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>
安装完成
本文出自 “站在巨人的肩膀上看世界” 博客,请务必保留此出处http://lixiaotao.blog.51cto.com/985722/1692864
标签:mysql
原文地址:http://lixiaotao.blog.51cto.com/985722/1692864