mysql 8.0.18 安裝配置方法圖文教程(linux)
本文記錄了linux mysql 8.0.18 安裝配置圖文教程,供大家參考,具體內(nèi)容如下
1、官網(wǎng)安裝包下載地址
2、我這里通過xftp將安裝包上傳至Linux服務器
3.解壓
解壓命令:tar -xvf mysql-8.0.18-linux-glibc2.12-x86_64.tar
繼續(xù)解壓需要的那一個
命令: tar -xvf mysql-8.0.18-linux-glibc2.12-x86_64.tar.xz
重命名并移動到合適的路徑
重命名 : mv mysql-8.0.18-linux-glibc2.12-x86_64 mysql
移動:
4.在/usr/local/mysql下創(chuàng)建data文件夾
# mkdir data
5.初始化數(shù)據(jù)庫,自動生成密碼 需記錄 等下要用
# bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
ps:中間遇到一個坑,初始化數(shù)據(jù)庫時候報了錯
具體錯誤為:bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
解決方法為:yum install libaio-devel.x86_64 原因是缺少了libaio這個東西 安裝就完事了
再次執(zhí)行初始化命令
得到初始化密碼,需要記下,一會會用到
6.修改/usr/local/mysql 當前目錄的用戶
# chown -R root:root ./ # chown -R mysql:mysql data
7.復制my-default.cnf這個文件到etc/my.cnf去
具體命令為:
# cd support-files/ # touch my-default.cnf # chmod 777 ./my-default.cnf # cd ../ # cp support-files/my-default.cnf /etc/my.cnf
8.完了之后配置my.cnf
vim /etc/my.cnf
內(nèi)容:
[mysqld] # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128M # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin # These are commonly set, remove the # and set as required. basedir = /usr/local/mysql datadir = /usr/local/mysql/data socket = /tmp/mysql.sock log-error = /usr/local/mysql/data/error.log pid-file = /usr/local/mysql/data/mysql.pid tmpdir = /tmp port = 5186 #lower_case_table_names = 1 # server_id = ..... # socket = ..... #lower_case_table_names = 1 max_allowed_packet=32M default-authentication-plugin = mysql_native_password #lower_case_file_system = on #lower_case_table_names = 1 log_bin_trust_function_creators = ON # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
如果后期mysql運行報錯,可以直接到log-error = /usr/local/mysql/data/error.log目錄下直接查看錯誤日志
命令:cat /usr/local/mysql/data/error.log
9.開機自啟,進入/usr/local/mysql/support-files進行設置
# cd support-files/ # cp mysql.server /etc/init.d/mysql # chmod +x /etc/init.d/mysql
10.注冊服務
# chkconfig --add mysql
11.查看是否成功
12.etc/ld.so.conf要配置路徑,不然報錯
# vim /etc/ld.so.conf
添加如下內(nèi)容:
/usr/local/mysql/lib
13.配置環(huán)境變量
# vim /etc/profile # source /etc/profile
添加如下內(nèi)容:
#MYSQL ENVIRONMENT export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib
14.登錄 需要用到上面的生成的密碼
#啟動mysql服務 [root@localhost bin]# service mysql start Starting MySQL.Logging to '/usr/local/mysql/data/error.log'. .. SUCCESS! [root@localhost bin]# #修改mysql密碼 mysql> alter user 'root'@'localhost' identified by '123456'; Query OK, 0 rows affected (0.02 sec) mysql>
ps:第二個坑,在啟動時出現(xiàn)錯誤 詳情為:
Starting MySQL...The server quit without updating PID file [FAILED]cal/mysql/data/mysql.pid).
該錯誤翻了一下午,繞了一大圈,最終問題是my.cnf文件配置問題,千萬不能以為加了#就是注釋掉了,自己檢查了n遍,覺得沒有錯,結(jié)果就是不行,沒有辦法找了一份另一臺服務器的my.cnf配置,復制替換稍加修改,解決問題。
大功告成!可以使用可視化工具進行數(shù)據(jù)庫連接了。
安裝完成。
精彩專題分享:
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關文章
利用MySQL函數(shù)實現(xiàn)判斷視頻擴展名的代碼
MySQL擁有強大的自定義函數(shù)功能,如下,我寫了一個用MySQL函數(shù) 判斷視頻地址是否可以手機端播放2012-02-02Mysql 存在多條數(shù)據(jù)時如何按時間取最新的那一組數(shù)據(jù)(思路詳解)
這篇文章主要介紹了Mysql 存在多條數(shù)據(jù)時如何按時間取最新的那一組數(shù)據(jù),本文給大家分享兩種思路結(jié)合實例代碼給大家介紹的非常詳細,需要的朋友可以參考下2024-04-04MySQL入門(四) 數(shù)據(jù)表的數(shù)據(jù)插入、更新、刪除
這篇文章主要介紹了mysql數(shù)據(jù)庫中表的插入、更新、刪除非常簡單,但是簡單的也要學習,細節(jié)決定成敗,需要的朋友可以參考下2018-07-07MySQL性能優(yōu)化之max_connections配置參數(shù)淺析
這篇文章主要介紹了MySQL性能優(yōu)化之max_connections配置參數(shù)淺析,本文著重講解了3種配置max_connections參數(shù)的方法,需要的朋友可以參考下2014-07-07