RHEL7.5下mysql 8.0.11安装教程
作者:rznice 时间:2024-01-27 13:43:49
本文记录了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不同版本安装教程
mysql5.7各版本安装教程
mysql5.6各版本安装教程
mysql8.0各版本安装教程
来源:https://blog.csdn.net/rznice/article/details/80045095
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
python argparser的具体使用
go HTTP2 的头部压缩算法hpack实现详解
![](https://img.aspxhome.com/file/2023/5/123975_0s.png)
python为QT程序添加图标的方法详解
![](https://img.aspxhome.com/file/2023/4/83754_0s.png)
python根据用户需求输入想爬取的内容及页数爬取图片方法详解
![](https://img.aspxhome.com/file/2023/4/69024_0s.png)
Python命令启动Web服务器实例详解
SQL Server存储过程入门学习
SQL 中having 和where的区别分析
asp是什么格式 asp文件用什么打开
在pycharm上mongodb配置及可视化设置方法
![](https://img.aspxhome.com/file/2023/5/125045_0s.jpg)
在Django的URLconf中使用命名组的方法
Python中私有属性的定义方式
Python实现替换文件中指定内容的方法
多次执行mysql_fetch_array()的指针归位问题探讨
分布式爬虫scrapy-redis的实战踩坑记录
![](https://img.aspxhome.com/file/2023/9/120969_0s.png)
微信小程序中做用户登录与登录态维护的实现详解
![](https://img.aspxhome.com/file/2023/3/136963_0s.png)
JavaScript 组件之旅(二):编码实现和算法
mysql主从复制读写分离的配置方法详解
![](https://img.aspxhome.com/file/2023/7/71717_0s.png)
Python DataFrame.groupby()聚合函数,分组级运算
深入探究Django中的Session与Cookie
python 使用百度AI接口进行人脸对比的步骤
![](https://img.aspxhome.com/file/2023/7/68477_0s.png)