Linux非ROOT(普通用户)环境安装/启动/运行 MySQL server CentOS7为例

假设用户名umysql,需要把mysql安装到用户目录下  /home/umysql/mysql (~/mysql)

 

1. 安装Mysql基础依赖包:

yum install -y libaio numactl

 

2.下载Mysql软件包

在 MySQL 网站上找到需要的版本,以5.7为例

https://dev.mysql.com/downloads/mysql/

cd /home/umysql/mysql
wget
https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-community-server-5.7.22-1.el7.x86_64.rpm wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-community-common-5.7.22-1.el7.x86_64.rpm wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-community-libs-5.7.22-1.el7.x86_64.rpm

 

3.解压软件包

rpm2cpio mysql-community-server-5.7.22-1.el7.x86_64.rpm | cpio -idvm
rpm2cpio mysql-community-common-5.7.22-1.el7.x86_64.rpm | cpio -idvm
rpm2cpio mysql-community-libs-5.7.22-1.el7.x86_64.rpm | cpio -idvm

 

4.设置环境变量

echo 'export PATH=$PATH:/home/umysql/mysql/usr/bin/:/home/umysql/mysql/usr/sbin/' >> /home/umysql/.bashrc
source /home/umysql/.bashrc

 

5.编辑my.cnf

vi /home/umysql/mysql/etc/my.cnf

[mysqld]
symbolic-links=0

socket=/home/umysql/mysql/var/lib/mysql/mysql.sock

basedir=/home/umysql/mysql/usr
datadir=/home/umysql/mysql/var/lib/mysql/data
secure-file-priv=/home/umysql/mysql/var/lib/mysql-files

init-connect=\'SET NAMES utf8\'
collation_server=utf8_unicode_ci
character_set_server=utf8

 

6. 安装mysql

注意这个步骤生成的默认密码

mysqld --defaults-file=/home/umysql/mysql/etc/my.cnf --initialize --user=umysql

 

7.启动mysql

mysqld --defaults-file=/home/umysql/mysql/etc/my.cnf --user=umysql &

 

大功告成~ 可以用netstat检查一下mysql是否运行

netstat -nl | grep 3306

 

posted @ 2018-07-16 17:46  Parasis  阅读(12577)  评论(0编辑  收藏  举报