时间:2021-07-01 10:21:17 帮助过:49人阅读
测试环境:CentOS6.6
下载地址:https://www.percona.com/downloads/Percona-Server-5.6/Percona-Server-5.6.28-76.1/
安装版本:percona-server-5.6(或者5.5)
二进制包安装过程:
前提:
1.防火墙关闭(如果未做火墙策略)
2.selinux 关闭
部署:
1.依赖包安装:
yum -y install openssl098e.x86_64 openssl.x86_64 openssl-devel.x86_64
可能需要的依赖包:
yum -y install compat-readline5.x86_64
perl模块安装:
yum install -y perl-DBD-MySQL.x86_64 perl-IO-Socket-SSL.noarch
2.目录创建
Data目录:
mkdir -pv /data/mysql/Datadir/m1/data
mkdir -pv /data/mysql/Datadir/m1/tmp
Log目录 :
mkdir -pv /data/mysql/Logdir/m1/logs
配置文件目录:
mkdir -pv /data/mysql/config
socket目录:
mkdir -pv /data/mysql/socket
(备注1:m1:实例名,随便指定,多实例情况下,用来区分路径)
(备注2:/data存储挂载目录;为和其它业务目录区分,单独创建mysql目录,放data,log,config,socket相关文件目录。这些目录需要在配置文件里指定,否则无法识别)
3.创建用户(可以是非mysql,只不过在使用--user=xx,时指定就行)
groupadd mysql
useradd -g mysql mysql
4.安装mysql
<1>解压:<提前把压缩包上传到/data 下面>
执行命令:
cd /data/
tar -xf Percona-Server-5.6.28-rel76.1-Linux.x86_64.ssl098e.tar.gz
<2>改名
mv Percona-Server-5.6.28-rel76.1-Linux.x86_64.ssl098e.tar.gz mysql5628
<3>软链
ln -s /data/mysql5628 /usr/local/mysql
5.环境变量设置
vim /etc/profile
export PATH=$PATH:/usr/local/mysql/bin
TMOUT=600 #超时时间需要设置长点,不然屏幕显示老是中断
保存退出!
执行:source /etc/profile
6.配置文件(包里弄好了配置文件)
/data/config/my3306.cnf
一些主要路径参数:
[mysqld]
basedir = /usr/local/mysql
datadir = /data/mysql/Datadir/m1/data
tmpdir = /data/mysql/Datadir/m1/tmp
socket = /data/mysql/socket/mysql3306.sock
pid-file = /data/mysql/socket/mysql3306.pid
log-bin = /data/mysql/Logdir/m1/logs/mysql-bin
log-error = /data/mysql/Logdir/m1/m1_err.log
slow-query-log-file = /data/mysql/Logdir/m1/m1_slow.log
#innodb
innodb_data_home_dir = /data/mysql/Datadir/m1/data
innodb_log_group_home_dir = /data/mysql/Logdir/m1/logs
innodb_data_file_path = ibdata1:1G:autoextend
innodb_buffer_pool_size = 4G #根据服务器内存大小调整(单实例的话,本地内存的70%~80%吧)
7.赋权:属组 (为了方便组和用户都是mysql权限,详细可以参考官方文档安装部分)
chown -R mysql.mysql /data/mysql
chown -R mysql.mysql /usr/local/mysql
8.初始化(初始化成功会显示 OK..OK.. 还有一些启动的信息。如果初始化,几秒钟就结束,恭喜你 估计有问题,建议看下err_log)
cd /usr/local/mysql/
./scripts/mysql_install_db --defaults-file=/data/config/my3306.cnf --user=mysql
9.启动方式:
./bin/mysqld_safe --defaults-file=/data/config/my3306.cnf --user=mysql &
10.登录方式:
mysql -uroot -p -S /data/mysql/socket/mysql3306.sock
(备注:第一次root登录,无密码,直接登录,回车,进库)
11.查看当前用户
select user,host,password from mysql.user;
清除无用的用户:
delete from mysql.user where user=‘ ‘ or host !=‘localhost‘;
设置root密码:
grant all privileges on *.* to root@‘localhost‘ identified by ‘root@!1234‘ with grant option;
设置管理员账号:
grant all privileges on *.* to admin@‘%‘ identified by ‘admin@!1234‘ with grant option;
grant all privileges on *.* to admin@‘localhost‘ identified by ‘admin@!1234‘ with grant option;
设置普通账户:
grant SELECT,DELETE,INSERT, UPDATE, CREATE, PROCESS,ALTER ON db1.* to user01@‘%‘ identified by ‘userpasswd‘;
刷新权限:
flush privileges;
---OK
[备注:内容如有错误之处,望指出,共同进步]
本文出自 “清风” 博客,请务必保留此出处http://11805203.blog.51cto.com/11795203/1828879
MySQL Install for Linux
标签:mysql 安装 install