1、下载MysqL-5.7.24-linux-glibc2.12-x86_64.tar.gz(/opt目录)
2、tar -zxvf MysqL-5.7.24-linux-glibc2.12-x86_64.tar.gz
3、改名称。mv MysqL-5.7.24-linux-glibc2.12-x86_64 MysqL,在MysqL目录下创建data目录,mkdir data
4、在/etc下新建my.cnf。内容如下
#[MysqLd]
#datadir=/var/lib/MysqL
#socket=/var/lib/MysqL/MysqL.sock
# disabling symbolic-links is recommended to prevent assorted security risks
#symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run MysqLd under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
[MysqLd_safe]
log-error=/var/log/MysqLd.log
pid-file=/opt/MysqL/data/MysqLd.pid
#
# include all files from the config directory
#
#!includedir /etc/my.cnf.d
[client]
port = 3306
socket = /opt/MysqL/MysqL.sock
default-character-set=utf-8
[MysqLd]
#skip-grant-tables
character_set_server=utf8
init_connect=‘SET NAMES utf8‘
basedir=/opt/MysqL
datadir=/opt/MysqL/data
socket=/opt/MysqL/MysqL.sock
lower_case_table_names = 1
bind-address = 0.0.0.0
sql_mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
touch MysqL.sock
chown MysqL:MysqL MysqL.sock
chmod 755 MysqL.sock
6、
查看组和用户情况:cat /etc/group | grep MysqL
查看组和用户情况:cat /etc/passwd |grep MysqL
若存在,则删除原MysqL用户:userdel -r MysqL,会删除其对应的组和用户并在次查看。
创建MysqL组:groupadd MysqL
创建MysqL用户:useradd -r -g MysqL MysqL
修改目录拥有者:chown -R MysqL:MysqL /opt/MysqL
7、cd /opt/MysqL/bin/目录
./MysqLd --user=MysqL --basedir=/opt/MysqL --datadir=/opt/MysqL/data --initialize(需要记住初始密码)
8、./MysqLd_safe --user=MysqL &
9、./MysqL -u root -p
输入初始密码
10、改密码:MysqL>set password=password("123456");
11、MysqL>grant all privileges on *.* to ‘root‘@‘%‘ identified by ‘123456‘;
12、flush privileges;
13、set global show_compatibility_56=on;
14、MysqL> quit;
15、cp -a /opt/MysqL/support-files/MysqL.server /etc/init.d/MysqL
16、ln -s /opt/MysqL/bin/MysqL /usr/bin
参考:
https://www.cnblogs.com/songyinan/p/10093288.html
https://blog.csdn.net/demored/article/details/54341246
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。