Linux环境下java开发环境搭建三 mysql解压安装(预编译安装)

Linux环境下java开发环境搭建三 mysql解压安装(预编译安装),第1张

概述第一步下载linux环境下的安装包,并把安装包解压到/usr/local/目录下 解压后的文件如下 第二步:安装前的一些准备工作 (1)建立软链接 #ln  -s mysql-5.7.25-linux-glibc2.12-x86_64   mysql (2)创建mysql组与mysql 用户 #groupadd msyql 创建的mysql用户不能登录只是用来启动mysql数据库,且其家目录为/u 第一步下载linux环境下的安装包,并把安装包解压到/usr/local/目录下

解压后的文件如下

第二步:安装前的一些准备工作 (1)建立软链接

#ln  -s MysqL-5.7.25-linux-glibc2.12-x86_64   MysqL

(2)创建MysqL组与MysqL 用户

#groupadd msyql

创建的MysqL用户不能登录只是用来启动MysqL数据库,且其家目录为/usr/local/MysqL,并不是/home/MysqL

#useradd -r -s /sbin/nologin -g MysqL MysqL -d /usr/local/MysqL

(3)在/user/local/目录下创建MysqL-files目录,且赋予750权限

#mkdir MysqL-file

#chmod 750 MysqL-files

 

(4)把/user/local/MysqL目录的所属用户设置成MysqL用户,所属组都设置成MysqL组

 

第三步:MysqL的安装 (1)使用/usr/local/MysqL/bin目录下的MysqLd进行初始化
[[email protected] MysqL]# bin/MysqLd --initialize --user=MysqL --basedir=/usr/local/MysqL --datadir=/usr/local/MysqL/data

--user=MysqL                                  代表初始化时,使用的linux用户是MysqL用户

--basedir=/usr/local/MysqL             代表MysqL安装的目录是/usr/local/MysqL

--datadir=/usr/local/MysqL/data      代表MysqL以后的数据库都存放在/usr/local/MysqL/data

注意的一点就是如果/etc/my.cnf文件存在,一些配置信息会读取这个配置文件中的内容,如果在这个文件中配置了 log-error ,那么MysqL的初始化过程不会打印到标准输出中,而是输出到log-error配置的文件中。初始化中会给出一个root的初始化密码,要记住

(2)在/etc/目录下创建配置文件,/etc/my.cnf
[MysqLd]basedir=/usr/local/MysqLdatadir=/usr/local/MysqL/datauser=MysqL# disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0default-storage-engine=InnoDBinnodb-file-per-table=1character_set_server=utf8mb4[MysqLd_safe][clIEnt]default-character-set=utf8mb4
(3)启动MysqL

方法一:手动启动

#MysqLd_safe   --user=MysqL &

方法二:使用安装包中的MysqL.server脚本启动

首先把脚本复制到linux的/etc/init.d/  目录下,然后把MysqL.server重命名为MysqLd

再重命名后的MysqLd设置成开机启动

 

[[email protected] MysqL]# cp ./support-files/MysqL.server /etc/init.d/[[email protected] MysqL]# mv /etc/init.d/MysqL.server /etc/init.d/MysqLd[[email protected] MysqL]# chkconfig --add MysqLd[[email protected] MysqL]# chkconfig MysqLd on

启动MysqL

[[email protected] MysqL]# service MysqLd startStarting MysqL.Logging to /usr/local/MysqL/data/slave1.err. SUCCESS!

查看一些MysqLd的启动情况

[[email protected] MysqL]# ps aux| grep MysqLdroot      1689  0.1  0.1  11436  1540 pts/2    S    18:12   0:00 /bin/sh /usr/local/MysqL/bin/MysqLd_safe --datadir=/usr/local/MysqL/data --pID-file=/usr/local/MysqL/data/slave1.pIDMysqL     1861  4.0 17.6 1168192 180332 pts/2  Sl   18:12   0:00 /usr/local/MysqL/bin/MysqLd --basedir=/usr/local/MysqL --datadir=/usr/local/MysqL/data --plugin-dir=/usr/local/MysqL/lib/plugin --user=MysqL --log-error=slave1.err --pID-file=/usr/local/MysqL/data/slave1.pIDroot      1891  0.0  0.0 103248   868 pts/2    S+   18:12   0:00 grep MysqLd

可以看到,其实采用脚本启动调用的也是MysqLd_safe命令

(4)把/usr/local/MysqL/bin目录加入到linux的PATH变量,这样在使用/usr/local/MysqL/bin目录下的命令时,就不需要进入到bin目录,或者写上路径名

export MysqL_HOME=/usr/local/MysqL/export PATH=$PATH:$MysqL_HOME/bin

或者

[[email protected] MysqL]# echo "export PATH=$PATH:/usr/local/MysqL/bin" >> /etc/profile

(5)使/etc/profile 配置文件重新生效

[[email protected] MysqL]# source /etc/profile

 

(6) 此时就可以登录通过 #MysqL -uroot -p‘密码‘登录了

[[email protected] MysqL]# MysqL -uroot -pEnter password: Welcome to the MysqL monitor.  Commands end with ; or \g.Your MysqL connection ID is 2Server version: 5.7.25copyright (c) 2000,2019,Oracle and/or its affiliates. All rights reserved.Oracle is a registered Trademark of Oracle Corporation and/or itsaffiliates. Other names may be Trademarks of their respectiveowners.Type help; or \h for help. Type \c to clear the current input statement.

首次登录需要重置密码

MysqL> show databases;ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
MysqL> alter user [email protected]localhost IDentifIEd by ‘********;

通过alter语句对密码进行重置,密码要复核一些原则,数字,字母,大小写,特殊字符等.

总结

以上是内存溢出为你收集整理的Linux环境下java开发环境搭建三 mysql解压安装(预编译安装)全部内容,希望文章能够帮你解决Linux环境下java开发环境搭建三 mysql解压安装(预编译安装)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/yw/1027778.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存