您好,登錄后才能下訂單哦!
這篇文章將為大家詳細(xì)講解有關(guān)linux中如何安裝配置mysql8.0.18,小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。
本文記錄了linux mysql 8.0.18 安裝配置圖文教程,供大家參考,具體內(nèi)容如下
1、官網(wǎng)安裝包下載地址
2、我這里通過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ù)庫,自動(dòng)生成密碼 需記錄 等下要用
# bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
ps:中間遇到一個(gè)坑,初始化數(shù)據(jù)庫時(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)前目錄的用戶
# 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.開機(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.注冊服務(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ò)誤翻了一下午,繞了一大圈,最終問題是my.cnf文件配置問題,千萬不能以為加了#就是注釋掉了,自己檢查了n遍,覺得沒有錯(cuò),結(jié)果就是不行,沒有辦法找了一份另一臺(tái)服務(wù)器的my.cnf配置,復(fù)制替換稍加修改,解決問題。
大功告成!可以使用可視化工具進(jìn)行數(shù)據(jù)庫連接了。
安裝完成。
關(guān)于“l(fā)inux中如何安裝配置mysql8.0.18”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,使各位可以學(xué)到更多知識(shí),如果覺得文章不錯(cuò),請把它分享出去讓更多的人看到。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。