本文記錄了RHEL7.5下mysql 8.0.11安裝教程,具體內(nèi)容如下
首先去mysql官網(wǎng)下載mysql-8.0.11-el7-x86_64.tar 解壓。
由于mysql初始化、啟動都需要用到mysql用戶,所以創(chuàng)建一個mysql用戶:
useradd -d /home/mysql -m -s /bin/bash mysql
經(jīng)過測試發(fā)現(xiàn)系統(tǒng)中裝有mariadb相關(guān)的mysql啟動的時候會報錯,于是卸載和mariadb相關(guān)的包。
[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!
使用如下命令初始化數(shù)據(jù)庫,會在把/var/lib/mysql作為data文件的目錄:
shell> bin/mysqld --initialize --user=mysql
于是我們可以在初始化的時候指定相應(yīng)的文件目錄:
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 就會出現(xiàn)如下的提示:
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用戶的密碼,再做其他操作:
RHEL7的服務(wù)systemctl腳本存放在:/usr/lib/systemd/,有系統(tǒng)(system)和用戶(user)之分,像需要開機不登陸就能運行的程序,還是存在系統(tǒng)服務(wù)里吧,即:/usr/lib/systemd/system目錄下
每一個服務(wù)以.service結(jié)尾,一般會分為3部分:[Unit]、[Service]和[Install],現(xiàn)在把MYSQL添加進去,具體內(nèi)容如下:
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來 啟動,重啟,關(guān)閉mysql服務(wù)。
精彩專題分享:
mysql不同版本安裝教程
mysql5.7各版本安裝教程
mysql5.6各版本安裝教程
mysql8.0各版本安裝教程
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
您可能感興趣的文章:- mysql 8.0.11 安裝步驟詳解
- mysql 8.0.11安裝配置方法圖文教程
- mysql 8.0.11 macos10.13安裝配置方法圖文教程
- mysql 8.0.11 winx64安裝配置方法圖文教程
- mysql 8.0.12 安裝配置方法圖文教程
- mysql 8.0.12 安裝配置圖文教程
- mysql 8.0.12 解壓版安裝教程
- mysql installer community 8.0.12.0安裝圖文教程
- mysql 8.0.12 安裝配置方法并修改密碼
- mysql 8.0.11 MSI版安裝配置圖文教程