linux mysql自定义安装路径_centos 7 安装 mysql5.7,自定义目录

平台: centos 7

shell命令:

8f900a89c6347c561fdf2122f13be562.png

961ddebeb323a10fe0623af514929fc1.png

shell> yumsearch libaio

shell> yum installlibaio

shell> mkdir /home/admin/temp

shell> mkdir /prod/db

shell> cd /home/admin/temp

shell> wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.27-linux-glibc2.12-x86_64.tar.gz

shell> tar -axvf mysql-5.7.27-linux-glibc2.12-x86_64.tar.gz -C /prod/db

shell> mv /prod/db/mysql-5.7.27-linux-glibc2.12-x86_64 mysql

shell> cd /prod/db/mysql

shell> lsshell>groupadd mysql

shell> useradd -r -g mysql -s /bin/falsemysql

shell> ln -s /prod/db/mysql mysql

shell> mysql/bin/mysqld --user=mysql --basedir=/prod/db/mysql --datadir=/prod/db/mysql/data/ --initialize

shell

mysql命令

8f900a89c6347c561fdf2122f13be562.png

961ddebeb323a10fe0623af514929fc1.png

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'yourpassword'WITH GRANT OPTION;

FLUSH PRIVILEGES;

exit

View Code

my.cnf配置文件:

8f900a89c6347c561fdf2122f13be562.png

961ddebeb323a10fe0623af514929fc1.png

[client]port= 3306socket= /prod/db/mysql/mysql.sock[mysqld]port= 3306basedir=/prod/db/mysql

datadir=/prod/db/mysql/data

socket=/prod/db/mysql/mysql.sock

pid-file=/prod/db/mysql/mysql.pid

explicit_defaults_for_timestamp

log_error=/prod/db/mysql/log/mysql-error.logslow_query_log_file=/prod/db/mysql/log/mysql-slow.log

View Code

本次使用的安装包url: https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.27-linux-glibc2.12-x86_64.tar.gz

90d18e85633c4906ea05cb3009d32456.png

f67f0df44081b1108847068f407bde08.png

mysql5.7x依赖库: libaio

查询是否已安装依赖库: yum search libaio

linux mysql自定义安装路径_centos 7 安装 mysql5.7,自定义目录_第1张图片

安装依赖库: yum install libaio

linux mysql自定义安装路径_centos 7 安装 mysql5.7,自定义目录_第2张图片

创建临时目录: mkdir /home/admin/temp

2d979535185a842ad6b450b3a930c67b.png

新建软件安装目录:  mkdir /prod/db

082aff983fbe2965cdaeef6949bea364.png

进入templ目录: cd /home/admin/temp

760472dc63a1b35a267941ebcb3c7b94.png

下载安装包: wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.27-linux-glibc2.12-x86_64.tar.gz

244b74558cdc9030c14abf3d556b029b.png

解压安装包,到软件安装目录(-C 是指定解压的目标目录): tar -axvf mysql-5.7.27-linux-glibc2.12-x86_64.tar.gz -C /prod/db

68f724bad5a33d9a9f6bd2ca7369ecb7.png

重命名mysql: mv /prod/db/mysql-5.7.27-linux-glibc2.12-x86_64 mysql

d7cd1c45e813212e467a1243d051db12.png

进入mysql目录: cd /prod/db/mysql

查询mysql目录文件: ls

创建mysql用户组:groupadd mysql

创建mysql用户(-s /bin/false 是禁止用户登录centos系统):useradd -r -g mysql -s /bin/false mysql

创建软连接: ln -s /prod/db/mysql mysql

初始化mysql环境:mysql/bin/mysqld --user=mysql --basedir=/prod/db/mysql --datadir=/prod/db/mysql/data/  --initialize

得到mysql的临时登录密码:

使用临时密码登录:mysql -u root -p"刚刚得到临时的密码"

修改密码(password() 里面填写你要设定的密码):set password=password('yourpassword');

设置远程登录:GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;

重载授权表:FLUSH PRIVILEGES;

退出mysql数据库:exit

1b7fef529f5108ce4a1e7ad2791c1304.png

你可能感兴趣的:(linux,mysql自定义安装路径)