mysql 8.0.18 安裝配置方法圖文教程(linux)
本文記錄了linux mysql 8.0.18 安裝配置圖文教程,供大家參考,具體內(nèi)容如下
1、官網(wǎng)安裝包下載地址
2、我這里通過(guò)xftp將安裝包上傳至Linux服務(wù)器
3.解壓
解壓命令:tar -xvf mysql-8.0.18-linux-glibc2.12-x86_64.tar
繼續(xù)解壓需要的那一個(gè)
命令: tar -xvf mysql-8.0.18-linux-glibc2.12-x86_64.tar.xz
重命名并移動(dòng)到合適的路徑
重命名 : mv mysql-8.0.18-linux-glibc2.12-x86_64 mysql
移動(dòng):
4.在/usr/local/mysql下創(chuàng)建data文件夾
# mkdir data
5.初始化數(shù)據(jù)庫(kù),自動(dòng)生成密碼 需記錄 等下要用
# bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
ps:中間遇到一個(gè)坑,初始化數(shù)據(jù)庫(kù)時(shí)候報(bào)了錯(cuò)
具體錯(cuò)誤為: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這個(gè)東西 安裝就完事了
再次執(zhí)行初始化命令
得到初始化密碼,需要記下,一會(huì)會(huì)用到
6.修改/usr/local/mysql 當(dāng)前目錄的用戶(hù)
# chown -R root:root ./ # chown -R mysql:mysql data
7.復(fù)制my-default.cnf這個(gè)文件到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運(yùn)行報(bào)錯(cuò),可以直接到log-error = /usr/local/mysql/data/error.log目錄下直接查看錯(cuò)誤日志
命令:cat /usr/local/mysql/data/error.log
9.開(kāi)機(jī)自啟,進(jìn)入/usr/local/mysql/support-files進(jìn)行設(shè)置
# cd support-files/ # cp mysql.server /etc/init.d/mysql # chmod +x /etc/init.d/mysql
10.注冊(cè)服務(wù)
# chkconfig --add mysql
11.查看是否成功
12.etc/ld.so.conf要配置路徑,不然報(bào)錯(cuò)
# 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.登錄 需要用到上面的生成的密碼
#啟動(dòng)mysql服務(wù) [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:第二個(gè)坑,在啟動(dòng)時(shí)出現(xiàn)錯(cuò)誤 詳情為:
Starting MySQL...The server quit without updating PID file [FAILED]cal/mysql/data/mysql.pid).
該錯(cuò)誤翻了一下午,繞了一大圈,最終問(wèn)題是my.cnf文件配置問(wèn)題,千萬(wàn)不能以為加了#就是注釋掉了,自己檢查了n遍,覺(jué)得沒(méi)有錯(cuò),結(jié)果就是不行,沒(méi)有辦法找了一份另一臺(tái)服務(wù)器的my.cnf配置,復(fù)制替換稍加修改,解決問(wèn)題。
大功告成!可以使用可視化工具進(jìn)行數(shù)據(jù)庫(kù)連接了。
安裝完成。
精彩專(zhuān)題分享:
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
利用MySQL函數(shù)實(shí)現(xiàn)判斷視頻擴(kuò)展名的代碼
MySQL擁有強(qiáng)大的自定義函數(shù)功能,如下,我寫(xiě)了一個(gè)用MySQL函數(shù) 判斷視頻地址是否可以手機(jī)端播放2012-02-02Mysql 存在多條數(shù)據(jù)時(shí)如何按時(shí)間取最新的那一組數(shù)據(jù)(思路詳解)
這篇文章主要介紹了Mysql 存在多條數(shù)據(jù)時(shí)如何按時(shí)間取最新的那一組數(shù)據(jù),本文給大家分享兩種思路結(jié)合實(shí)例代碼給大家介紹的非常詳細(xì),需要的朋友可以參考下2024-04-04MySQL中隨機(jī)生成固定長(zhǎng)度字符串的方法
在MySQL中有時(shí)需要隨機(jī)生成數(shù)字或字符串,隨機(jī)生產(chǎn)數(shù)字可直接使用rand()函數(shù),但是要隨機(jī)生成字符串就比較麻煩。2010-12-12MySQL入門(mén)(四) 數(shù)據(jù)表的數(shù)據(jù)插入、更新、刪除
這篇文章主要介紹了mysql數(shù)據(jù)庫(kù)中表的插入、更新、刪除非常簡(jiǎn)單,但是簡(jiǎn)單的也要學(xué)習(xí),細(xì)節(jié)決定成敗,需要的朋友可以參考下2018-07-07mysql 月份查詢(xún)?cè)撛掠懈犊畹臄?shù)據(jù)
mysql選擇月份查詢(xún)?cè)撛掠懈犊畹臄?shù)據(jù)(間隔x月并提前5天付款)2010-04-04MySQL性能優(yōu)化之max_connections配置參數(shù)淺析
這篇文章主要介紹了MySQL性能優(yōu)化之max_connections配置參數(shù)淺析,本文著重講解了3種配置max_connections參數(shù)的方法,需要的朋友可以參考下2014-07-07