RHEL7.5下mysql 8.0.11安装教程
程序员文章站
2022-03-14 17:58:02
本文记录了rhel7.5下mysql 8.0.11安装教程,具体内容如下
首先去mysql官网下载mysql-8.0.11-el7-x86_64.tar 解压。
由于...
本文记录了rhel7.5下mysql 8.0.11安装教程,具体内容如下
首先去mysql官网下载mysql-8.0.11-el7-x86_64.tar 解压。
由于mysql初始化、启动都需要用到mysql用户,所以创建一个mysql用户:
useradd -d /home/mysql -m -s /bin/bash mysql
经过测试发现系统中装有mariadb相关的mysql启动的时候会报错,于是卸载和mariadb相关的包。
[root@rhel mysql]# yum remove mariadb* loaded plugins: axelget, fastestmirror, langpacks, product-id, search-disabled- : repos, subscription-manager this system is not registered with an entitlement server. you can use subscription-manager to register. resolving dependencies --> running transaction check ---> package mariadb-libs.x86_64 1:5.5.56-2.el7 will be erased --> processing dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64 --> processing dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64 --> running transaction check ---> package postfix.x86_64 2:2.10.1-6.el7 will be erased --> finished dependency resolution epel/x86_64/group_gz | 266 kb 00:00 dependencies resolved ================================================================================ package arch version repository size ================================================================================ removing: mariadb-libs x86_64 1:5.5.56-2.el7 @base 4.4 m removing for dependencies: postfix x86_64 2:2.10.1-6.el7 @base 12 m transaction summary ================================================================================ remove 1 package (+1 dependent package) installed size: 17 m is this ok [y/n]: y downloading packages: running transaction check running transaction test transaction test succeeded running transaction erasing : 2:postfix-2.10.1-6.el7.x86_64 1/2 erasing : 1:mariadb-libs-5.5.56-2.el7.x86_64 2/2 no metadata available for base no metadata available for code no metadata available for epel no metadata available for extras no metadata available for updates loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * epel: mirrors.ustc.edu.cn * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com epel/x86_64/primary_db | 6.3 mb 00:01 verifying : 1:mariadb-libs-5.5.56-2.el7.x86_64 1/2 verifying : 2:postfix-2.10.1-6.el7.x86_64 2/2 removed: mariadb-libs.x86_64 1:5.5.56-2.el7 dependency removed: postfix.x86_64 2:2.10.1-6.el7 complete!
使用如下命令初始化数据库,会在把/var/lib/mysql作为data文件的目录:
shell> bin/mysqld --initialize --user=mysql
于是我们可以在初始化的时候指定相应的文件目录:
bin/mysqld --initialize --basedir=/home/mysql --datadir=/home/mysql/data --user=mysql
初始化的时候,会生成一个临时的密码,记住该密码,等登录到mysql的时候需要用这个密码,进去后再次修改密码。
启动mysql实例:
bin/mysqld --user=mysql bin/mysqld_safe basedir=/home/mysql --datadir=/home/mysql/data --user=mysql
如果不加 –user=mysql 就会出现如下的提示:
2018-04-22t15:47:25.471462z 0 [error] [my-010123] [server] fatal error: please read "security" section of the manual to find out how to run mysqld as root! 2018-04-22t15:47:25.471514z 0 [error] [my-010119] [server] aborting
造成mysql实例不能正常启动。
mysql启动后,使用root用户登录,使用刚刚随机生成的密码,进去后,通过如下命令修改root用户的密码,再做其他操作:
set password ='root';
rhel7的服务systemctl脚本存放在:/usr/lib/systemd/,有系统(system)和用户(user)之分,像需要开机不登陆就能运行的程序,还是存在系统服务里吧,即:/usr/lib/systemd/system目录下
每一个服务以.service结尾,一般会分为3部分:[unit]、[service]和[install],现在把mysql添加进去,具体内容如下:
cat /usr/lib/systemd/system/mysql.service [unit] description=mysql server after=network.target after=syslog.target [install] wantedby=multi-user.target [service] user=mysql group=mysql type=forking # execute pre and post scripts as root permissionsstartonly=true # start main service execstart=/home/mysql/bin/mysqld --daemonize execstop=kill -s -quit $mainpid restart=on-failure restartpreventexitstatus=1 privatetmp=false
就可以通过systemctl来 启动,重启,关闭mysql服务。
精彩专题分享:
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
推荐阅读
-
mysql 5.7以上版本安装配置方法图文教程(mysql 5.7.12mysql 5.7.13mysql 5.7.14)
-
Mysql5.7.17 winx64.zip解压缩版安装配置图文教程
-
linux下mysql的安装步骤
-
windows系统mysql5.7.18安装图文教程
-
Windows(x86,64bit)升级MySQL 5.7.17免安装版的详细教程
-
Windows10下mysql 5.7.17 安装配置方法图文教程
-
MySql 5.6.35 winx64 安装详细教程
-
mysql 5.7.13 安装配置方法图文教程(win10 64位)
-
mysql 5.7 安装配置方法图文教程
-
mysql 5.6.23 winx64.zip安装详细教程