wangli

come on

linux下mysql二进制方式安装

mysql的安装有很多种,rpm包、常规编译安装、cmake/gmake编译安装、二进制安装。

此次使用二进制方式安装

1、创建用户组、用户及相关目录

groupaddmysql
useradd-g mysql -d /var/lib/mysql mysql
mkdir-p /home/mysql/product/5.6/mysql-1
mkidr-p /home/mysql/data
mkidr-p /home/mysql/run
passwd mysql

2、 解压安装包,并拷贝到相应目录

cd/root
tarzxvf mysql-5.6.21-linux-glibc2.5-x86_64.tar.gz
cd mysql-5.6.21-linux-glibc2.5-x86_64
cp -r* /home/mysql/product/5.6/mysql-1/
chown-R mysql:mysql /home/mysql/data/
chown-R mysql:mysql /home/mysql/run/
chown-R root:mysql /home/mysql/product/

3、 配置相关文件

vi/etc/my.cnf
[mysqld]
basedir=/home/mysql/product/5.6/mysql-1
datadir=/home/mysql/data
socket=/home/mysql/run/mysql.sock
pid-file=/home/mysql/run/mysqld.pid
user=mysql
#Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
 
#开启bin log
log-bin=mysql-bin
log-bin-index=binlogs.index

skip-host-cache
skip-name-resolve
character-set-server=utf8
 
[client]
default-character-set=utf8
 
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

4、初始化mysql

cd /home/mysql/product/5.6/mysql-1/scipts
./mysql_install_db --basedir=/home/mysql/product/5.6/mysql-1 --datadir=/home/mysql/data--user=mysql

5、配置环境变量

/root/.bash_profile中添加
#MySQLEnv
exportMYSQL_BASE=/home/mysql
exportMYSQL_HOME=$MYSQL_BASE/product/5.6/mysql-1
exportDATADIR=$MYSQL_BASE/data
exportLD_LIBRARY_PATH=$MYSQL_HOME/lib:/lib:/usr/lib:/usr/local/lib 
exportTMPDIR=/tmp
exportPATH=$MYSQL_HOME/bin:$PATH
 
/root/.bashrc中添加
aliasmysql='mysql --socket=/home/mysql/run/mysql.sock'

6、配置系统服务

cp/home/mysql/product/5.6/mysql-1/mysql.server /etc/init.d/mysqld
servicemysqld start

7、创建root用户密码

mysql> grantall privileges on *.* to root@'%' identified by '123';

阅读更多
个人分类: Mysql
上一篇linux下mysql odbc配置
下一篇SAP DS mysql数据源配置
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭