您好,登錄后才能下訂單哦!
這篇文章主要講解了“怎么用二進制包安裝mysql”,文中的講解內容簡單清晰,易于學習與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學習“怎么用二進制包安裝mysql”吧!
本文主要講述如何使用二進制安裝mysql,并啟動mysql
https://dev.mysql.com/downloads/mysql/
上傳mysql安裝包至/usr/local目錄
解壓mysql安裝包;
[root@localhost local]# tar xvf mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz
將解壓后的文件夾連接至mysql文件夾
[root@localhost local]# ln -s mysql-5.6.39-linux-glibc2.12-x86_64 mysql
檢查并安裝依賴包(perl)
[root@localhost scripts]# yum -y install perl perl-devel perl-Data-Dumper
> 如若未安裝perl組件將會報以下錯誤
[root@localhost scripts]# ./mysql_install_db
FATAL ERROR: please install the following Perl modules before executing ./mysql_install_db:
Data::Dumper
- 檢查并安裝依賴包(libaio)
[root@localhost mysql]# yum list|grep libaio
libaio.i686 0.3.109-13.el7 base
libaio.x86_64 0.3.109-13.el7 base
libaio-devel.i686 0.3.109-13.el7 base
libaio-devel.x86_64 0.3.109-13.el7 base
[root@localhost mysql]# yum -y install libaio libaio-devel
> 若如為安裝libaio組件將會報以下錯誤
[root@localhost mysql]# scripts/mysql_install_db --user=mysql
WARNING: The host 'Alinx' could not be looked up with ./bin/resolveip.
This probably means that your libc libraries are not 100 % compatible
with this binary MySQL version. The MySQL daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MySQL privileges !
Installing MySQL system tables..../bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
[root@localhost mysql]#
### 3、創建mysql用戶,用戶組并將目錄授權給mysql用戶
[root@localhost scripts]# groupadd mysql
[root@localhost scripts]# useradd -r -g mysql mysql
[root@localhost ~]# chown mysql:mysql /usr/local/mysql -R
[root@localhost ~]# ll /usr/local/
total 321180
drwxr-xr-x. 2 root root 6 Aug 12 2015 bin
drwxr-xr-x. 2 root root 6 Aug 12 2015 etc
drwxr-xr-x. 2 root root 6 Aug 12 2015 games
drwxr-xr-x. 2 root root 6 Aug 12 2015 include
drwxr-xr-x. 2 root root 6 Aug 12 2015 lib
drwxr-xr-x. 2 root root 6 Aug 12 2015 lib64
drwxr-xr-x. 2 root root 6 Aug 12 2015 libexec
lrwxrwxrwx 1 mysql mysql 35 Jan 16 22:46 mysql -> mysql-5.6.39-linux-glibc2.12-x86_64
drwxr-xr-x 13 mysql mysql 4096 Jan 16 22:38 mysql-5.6.39-linux-glibc2.12-x86_64
-rw-r--r-- 1 root root 328882304 Jan 21 2018 mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz
drwxr-xr-x. 2 root root 6 Aug 12 2015 sbin
drwxr-xr-x. 5 root root 46 Jan 17 2017 share
drwxr-xr-x. 2 root root 6 Aug 12 2015 src
> 此時可以看到mysql目錄的歸屬為mysql:mysql - 刪除系統中的mysql配置文件
rm -f /etc/my.cnf
rm -fr /etc/my.cnf.d/
### 4、初始化并啟動mysql - 初始化
[root@localhost mysql]# scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data --skip-name-resolve
> 該步驟為創建了一個root用戶(空密碼),并初始化了mysql的一些權限賬戶表 - 拷貝配置文件以及啟動腳本
[root@localhost mysql]# cp support-files/my-default.cnf /etc/my.cnf
[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld
- 編輯/etc/my.cnf文件,并寫入如下內容
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data/
### 5、啟動mysql - 啟動mysql
/usr/local/mysql/support-files/mysqld start
- 為mysql數據庫設置密碼(跟進提示進行密碼設置,部署完時密碼為空)
[root@localhost mysql]# ./bin/mysql_secure_installation
- 登錄數據庫
[root@localhost mysql]# mysql -uroot -pAlinx
> 當前啟動時候報錯(發現是/etc/my.cnf未配置目錄導致)
[root@localhost support-files]# /usr/local/mysql/support-files/mysql.server start
Starting MySQL.Logging to '/usr/local/mysql/data/localhost.err'.
ERROR! The server quit without updating PID file (/usr/local/mysql/data/localhost.pid).
[root@localhost support-files]#
感謝各位的閱讀,以上就是“怎么用二進制包安裝mysql”的內容了,經過本文的學習后,相信大家對怎么用二進制包安裝mysql這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是億速云,小編將為大家推送更多相關知識點的文章,歡迎關注!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。