安装mysqlmysql-5.7.24-linux-glibc2.12-x86_64

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

5、在/opt/MysqL下新建文件MysqL.sock。

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

https://blog.csdn.net/eagle89/article/details/78411184

https://www.jianshu.com/p/8cb0189a3278

相关文章

/etc/sysctl.conf这个目录主要是配置一些系统信息,/etc/sys...
1.作用 useradd或adduser命令用来建立用户帐号和创建用户的起...
它们都是多模式编辑器,不同的是vim 是vi的升级版本,它不仅...
不管是我们在安装软件还是监测软件的使用性能,我们都要随时...
装好Tomcat7后,发现除了本机能访问外界访问不了,岂有此理。...
修改防火墙配置需要修改 /etc/sysconfig/iptables 这个文件,...