您好,登錄后才能下訂單哦!
這篇文章主要為大家展示了“l(fā)inux如何安裝mysql5.7的方法”,內(nèi)容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學(xué)習(xí)一下“l(fā)inux如何安裝mysql5.7的方法”這篇文章吧。
mysql 單節(jié)點安裝,前查詢:https://my.oschina.net/u/3411575/blog/5047890
步驟1:
自行下載mysql5.7
步驟2:
解壓:
tar -xvf mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz
步驟3:
移動解壓得到的文件夾,并重命名:
mv mysql-5.7.26-linux-glibc2.12-x86_64 /usr/local/mysql
步驟4:
創(chuàng)建文件夾
/home/mysql/data3306
/home/mysql/data3307
/home/mysql/data3309
步驟5:
編輯/etc/my.cnf
client] port=3306 socket=/tmp/mysql.sock [mysqld_multi] mysqld = /usr/local/mysql/bin/mysqld_safe mysqladmin = /usr/local/mysql/bin/mysqladmin log = /home/mysql/mysqld_multi.log [mysqld] user=mysql basedir = /usr/local/mysql sql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION [mysqld3306] mysqld=mysqld mysqladmin=mysqladmin datadir=/home/mysql/data3306/data port=3306 server_id=3306 socket=/tmp/data3306.sock log-output=file slow_query_log = 1 long_query_time = 1 slow_query_log_file = /home/mysql/mysql3306/log/slow.log log-error = /home/mysql/mysql3306/log/error.log binlog_format = mixed log-bin = /home/mysql/mysql3306/log/mysql3306_bin [mysqld3309] mysqld=mysqld mysqladmin=mysqladmin datadir=/home/mysql/data3308/data port=3309 server_id=3309 socket=/tmp/data3309.sock log-output=file slow_query_log = 1 long_query_time = 1 slow_query_log_file = /home/mysql/mysql3309/log/slow.log log-error = /home/mysql/mysql3309/log/error.log binlog_format = mixed log-bin = /home/mysql/mysql3309/log/mysql3309_bin
步驟6:
新建單獨實例的初始化配置文件(要與/etc/my.cnf文件配置保持一致) 分別存放在 /home/mysql/data3306 /home/mysql/data3307 /home/mysql/data3309 中
my.cnf(3306.cnf)
[client] port= 3306 socket= /home/mysql/data3306/mysql.sock default-character-set=utf8 [mysqld] user=mysql port=3306 basedir=/usr/local/mysql datadir=/home/mysql/data3306/data server_id=3306 socket=/home/mysql/data3306/mysql.sock log-output=file slow_query_log=1 long_query_time=1 slow_query_log_file=/home/mysql/data3306/log/slow.log symbolic-links=0 log-error=/home/mysql/data3306/log/error.log log-bin=/home/mysql/data3306/log/bin.log pid-file=/home/mysql/data3306/mysql3306.pid binlog_format=mixed lower-case-table_names=1 log-bin-trust-function-creators=1 sql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION character-set-server=utf8
my.cnf(3307.cnf)
[client] port= 3307 socket= /home/mysql/data3307/mysql.sock default-character-set=utf8 [mysqld] user=mysql port=3307 basedir=/usr/local/mysql datadir=/home/mysql/data3307/data server_id=3307 socket=/home/mysql/data3307/mysql.sock log-output=file slow_query_log=1 long_query_time=1 slow_query_log_file=/home/mysql/data3307/log/slow.log symbolic-links=0 log-error=/home/mysql/data3307/log/error.log log-bin=/home/mysql/data3307/log/bin.log pid-file=/home/mysql/data3307/mysql3307.pid binlog_format=mixed lower-case-table_names=1 log-bin-trust-function-creators=1 sql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION character-set-server=utf8
my.cnf(3309.cnf)
[client] port= 3309 socket= /home/mysql/data3309/mysql.sock default-character-set=utf8 [mysqld] user=mysql port=3309 basedir=/usr/local/mysql datadir=/home/mysql/data3309/data server_id=3309 socket=/home/mysql/data3309/mysql.sock log-output=file slow_query_log=1 long_query_time=1 slow_query_log_file=/home/mysql/data3309/log/slow.log symbolic-links=0 log-error=/home/mysql/data3309/log/error.log log-bin=/home/mysql/data3309/log/bin.log pid-file=/home/mysql/data3309/mysql3309.pid binlog_format=mixed lower-case-table_names=1 log-bin-trust-function-creators=1 sql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION character-set-server=utf8
步驟6-1:
創(chuàng)建文件夾/home/mysql/data330{6,7,9}/log并創(chuàng)建文件圖中4個文件
步驟7:
開始賦權(quán)限
chown mysql:mysql -R /home/mysql/ chown mysql:mysql -R /usr/local/mysql
步驟8:
初始化數(shù)據(jù)庫, 這里生成mysql.sock文件 :
/usr/local/mysql/bin/mysqld --defaults-file=/home/mysql/data3306/my.cnf --initialize --basedir=/usr/local/mysql/ --datadir=/home/mysql/data3306/data /usr/local/mysql/bin/mysqld_safe --defaults-file=/home/mysql/data3306/my.cnf & /usr/local/mysql/bin/mysqld --defaults-file=/home/mysql/data3307/my.cnf --initialize --basedir=/usr/local/mysql/ --datadir=/home/mysql/data3307/data /usr/local/mysql/bin/mysqld_safe --defaults-file=/home/mysql/data3307/my.cnf & /usr/local/mysql/bin/mysqld --defaults-file=/home/mysql/data3309/my.cnf --initialize --basedir=/usr/local/mysql/ --datadir=/home/mysql/data3309/data /usr/local/mysql/bin/mysqld_safe --defaults-file=/home/mysql/data3309/my.cnf &
這里會生成默認(rèn)密碼,可以去error.log中看
//-----------------------------------------以上-數(shù)據(jù)庫初始化完畢----
步驟9:
命令行中運行各個mysql實例:
/usr/local/mysql/bin/mysql -uroot -p -S /home/mysql/data3306/mysql.sock
輸入初始化密碼:
修改密碼:
SET PASSWORD = PASSWORD('123456'); ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER; FLUSH PRIVILEGES;
設(shè)置navicat可連接:
use mysql #訪問mysql庫 update user set host = '%' where user = 'root'; #使root能再任何host訪問 FLUSH PRIVILEGES; #刷新
步驟10:
navicat連接數(shù)據(jù)庫
停止節(jié)點:
查看進(jìn)程號 :ps aux | grep mysql
以上是“l(fā)inux如何安裝mysql5.7的方法”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學(xué)習(xí)更多知識,歡迎關(guān)注億速云行業(yè)資訊頻道!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。