MySQL5.7单实例安装及开机启动配置(亲测)

database

安装环境:

CentOS版本:CentOS7.6.1810

MySQL版本:5.7.9

软件目录:/soft

cp /soft/mysql-5.7.9-linux-glibc2.5-x86_64.tar.gz /usr/local/

解压mysql到/usr/local目录

tar -zxvf mysql-5.7.9-linux-glibc2.5-x86_64.tar.gz

安装需要的依赖

yum install -y libaio

具体安装:

shell> groupadd mysql

shell> useradd -r -g mysql mysql

shell> cd /usr/local

shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz

shell> ln -s full-path-to-mysql-VERSION-OS mysql

shell> cd mysql

shell> mkdir mysql-files

shell> chmod 770 mysql-files

shell> chown -R mysql .

shell> chgrp -R mysql .

shell> bin/mysqld --initialize --user=mysql # MySQL 5.7.6 and up

shell> bin/mysql_ssl_rsa_setup # MySQL 5.7.6 and up

shell> chown -R root .

shell> chown -R mysql data mysql-files

shell> bin/mysqld_safe --user=mysql &

# Next command is optional

shell> cp support-files/mysql.server /etc/init.d/mysql.server

配置环境变量:

export PATH=/usr/local/mysql/bin:$PATH

配置开启启动

chkconfig mysql.server on

chkconfig --list

登陆,修改密码

set password = ‘root1234%’;

允许远程登陆

GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘root1234%’

GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘root1234%’ WITH GRANT OPTION;

flush privileges;

启动的时候可能会报错

这是因为mysql启动的时候需要配置文件,而在安装centos的时候,哪怕是mini版本都会有个默认的配置在/etc目录中。

/usr/local/mysql/bin/mysqld --verbose --help |grep -A 1 ‘Default options’

Default options are read from the following files in the given order:

/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf

Mysql启动的时候会以上面所述的顺序加载配置文件

如果报错,先重命名my.cnf文件

以上是 MySQL5.7单实例安装及开机启动配置(亲测) 的全部内容, 来源链接: utcz.com/z/534994.html

回到顶部