mysql5.7部署
作者:互联网
链接:https://www.cnblogs.com/shidian/p/11589626.html
1.准备安装包
下载地址:https://dev.mysql.com/downloads/mysql/5.7.html#downloads
2.解压安装包
tar -xvf mysql-5.7.26-linux-glibc2.12-x86_64.tar
mv mysql-5.7.26-linux-glibc2.12-x86_64 /usr/local/mysql
3.创建MySQL用户组合用户并修改权限
groupadd mysql
useradd -r -g mysql mysql
4.创建数据目录并赋予权限。
mkdir -p /data/mysql #创建目录
chown mysql:mysql -R /data/mysql #赋予权限
5.配置my.cnf
vim /etc/my.cnf
[mysqld]
bind-address=0.0.0.0
port=3306
user=mysql
basedir=/data/mysql
datadir=/data/mysql
socket=/tmp/mysql.sock
log-error=/data/mysql/mysql.err
pid-file=/data/mysql/mysql.pid
#character config
character_set_server=utf8mb4
symbolic-links=0
explicit_defaults_for_timestamp=true
6.始化数据库
cd /date/mysql/bin/
./mysqld –defaults-file=/etc/my.cnf –basedir=/data/mysql/ –datadir=/data/mysql/ –user=mysql –initialize
7.启动MySQL服务
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
service mysql start
8.修改密码
cat /data/mysql/mysql.err。
SET PASSWORD = PASSWORD(‘123456’);
ALTER USER ‘root’@’localhost’ PASSWORD EXPIRE NEVER;
FLUSH PRIVILEGES;
9.远程连接
use mysql #访问mysql库
update user set host = ‘%’ where user = ‘root’; #使root能再任何host访问
FLUSH PRIVILEGES; #刷新
10.创建软连接
ln -s /usr/local/mysql/bin/mysql /usr/bin
标签:bin,部署,data,mysql5.7,usr,mysql,root,local 来源: https://www.cnblogs.com/leiuk/p/16434986.html