redhat mysql tar_mysql5.7版本tar包手动安装---redhat7.0
1.官網(wǎng)下載安裝包,刪除系統(tǒng)自帶的mariadb,查到幾個(gè)包,卸載幾個(gè)包,總之得刪除干凈
[root@localhost Desktop]# yum list |grep mariadb
mariadb-libs.x86_64 1:5.5.41-2.el7_0 @anaconda/7.1[root@localhost Desktop]# yum remove mariadb-libs.x86_64 -y ==>刪除這個(gè)包
[root@localhost Desktop]# yum list |grep mariadb ==>已經(jīng)查詢(xún)不到mariadb
[root@localhost Desktop]# ls
mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz ==>這是安裝包
2.創(chuàng)建用戶(hù)和組以及將安裝包移動(dòng)到安裝目錄(/usr/local/ )下
[root@localhost Desktop]# groupadd mysql
[root@localhost Desktop]# useradd-g mysql mysql
[root@localhost Desktop]# mv mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz /usr/local/[root@localhost Desktop]# cd/usr/local/[root@localhost local]# ls
bin games lib libexec sbin src
etc include lib64 mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz share
3.解壓安裝包,并文件重命名為mysql,刪除安裝包(也可以不刪除,有強(qiáng)迫癥的都會(huì)刪),確定安裝路徑是在 /usr/local 目錄下
[root@localhost local]# tar -zxvf mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz
[root@localhost local]# ls
bin include libexec sbin
etc lib mysql-5.7.16-linux-glibc2.5-x86_64 share
games lib64 mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz src
[root@localhost local]# mv mysql-5.7.16-linux-glibc2.5-x86_64 mysql ==>改名為mysql
[root@localhost local]# ls
bin games lib libexec mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz share
etc include lib64 mysql sbin src
[root@localhost local]# rm mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz
rm: remove regular file ‘mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz’?y
[root@localhost local]# ls
bin etc games include lib lib64 libexec mysql sbin share src
4.編輯配置文件/ect/my.cnf,把/usr/local/mysql/support-files/my-defaults-cnf復(fù)制到/etc/目錄下,并改名為my.cnf,也可以自己手動(dòng)創(chuàng)建編輯
[root@localhost support-files]# cp -a my-default.cnf /etc/my.cnf
[root@localhost local]# vim /etc/my.cnf
[mysql]
# 設(shè)置mysql客戶(hù)端默認(rèn)字符集default-character-set=utf8
socket=/tmp/mysql.sock
[mysqld]#設(shè)置3306端口
port= 3306socket=/tmp/mysql.sock
# 設(shè)置mysql的安裝目錄
basedir=/usr/local/mysql
# 設(shè)置mysql數(shù)據(jù)庫(kù)的數(shù)據(jù)的存放目錄
datadir=/usr/local/mysql/data
# 允許最大連接數(shù)
max_connections=200# 服務(wù)端使用的字符集默認(rèn)為utf-8編碼的latin1字符集
character-set-server=utf8
# 創(chuàng)建新表時(shí)將使用的默認(rèn)存儲(chǔ)引擎default-storage-engine=INNODBmax_allowed_packet=16M
5.初始化數(shù)據(jù)庫(kù)
MySQL5.7.6之前版本都是用mysql_install_db這個(gè)命令
[root@localhost local]# ./mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
到了5.7版本后已經(jīng)沒(méi)有scripts這個(gè)目錄,mysql_install_db也被移動(dòng)到了bin目錄下,5.7.6版本后這個(gè)命令已被棄用,若在5.7.6之后的版本用這個(gè)命令會(huì)報(bào)錯(cuò)
[root@localhost local]# ./mysql/bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
2018-12-10 13:42:04 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize ==>系統(tǒng)提示換成這個(gè)命令及參數(shù)2018-12-10 13:42:08 [ERROR] Child process: /usr/local/mysql/bin/mysqldterminated prematurely with errno= 32
2018-12-10 13:42:08 [ERROR] Failed to execute /usr/local/mysql/bin/mysqld --bootstrap --datadir=/usr/local/mysql/data --lc-messages-dir=/usr/local/mysql/share --lc-messages=en_US --basedir=/usr/local/mysql-- server log begin --
2018-12-10T05:42:04.757607Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead-- server log end --
5.7.6之后版本的初始化命令,在執(zhí)行前要確保 數(shù)據(jù)庫(kù)的 data 目錄 是一個(gè)空目錄,不讓也會(huì)報(bào)錯(cuò),處理方式是執(zhí)行 rf 清空目錄,報(bào)錯(cuò)信息如下
2018-12-10T11:08:53.586149Z 0 [ERROR] --initialize specifiedbut the data directory has files in it. Aborting.
開(kāi)始初始化數(shù)據(jù)庫(kù)
[root@localhost local]# ./mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ ==>5.7執(zhí)行初始化命令
2018-12-10T11:37:30.625023Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation formore details).2018-12-10T11:37:30.625070Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode ina future release.2018-12-10T11:37:30.625074Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.2018-12-10T11:37:32.454989Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-12-10T11:37:32.659920Z 0[Warning] InnoDB: Creating foreign key constraint system tables.2018-12-10T11:37:32.749779Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: fb994d89-fc6f-11e8-ab5f-4e052dd49fa2.2018-12-10T11:37:32.765740Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed'cannot be opened.2018-12-10T11:37:32.766627Z 1 [Note] A temporary password is generated for root@localhost: dsqO!0eNa>V2 ==>注意這個(gè)是初始的root密碼
6.設(shè)置開(kāi)機(jī)自動(dòng)啟動(dòng)腳本
復(fù)制啟動(dòng)腳本到/etc/rc.d/init.d/ 目錄下并命名為mysqld,確認(rèn)這個(gè)腳本具備X權(quán)限,若無(wú)執(zhí)行 chmod 加權(quán)限
[root@localhost local]# cp mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
[root@localhost local]# ll/etc/rc.d/init.d/mysqld-rwxr-xr-x. 1 root root 10886 Dec 10 19:49 /etc/rc.d/init.d/mysqld
把mysqld服務(wù)加入到系統(tǒng)服務(wù)
[root@localhost local]# chkconfig --add mysqld
[root@localhost local]# chkconfig--list |grep mysqld
Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.
If you want to list systemd services use'systemctl list-unit-files'.
To see services enabled on particular target use'systemctl list-dependencies [target]'.
mysqld0:off 1:off 2:on 3:on 4:on 5:on 6:off ==>服務(wù)已生效
7.啟動(dòng)數(shù)據(jù)庫(kù)服務(wù)
[root@localhost local]# service mysqld start
[root@localhost local]# service mysqld status
8.登入數(shù)據(jù)庫(kù)修改密碼,并設(shè)置允許遠(yuǎn)程登入
[root@localhost local]# /usr/local/mysql/bin/mysql -uroot -p'dsqO!0eNa>V2'mysql: [Warning] Using a password on the command lineinterfacecan be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection idis 5Server version:5.7.16Copyright (c)2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracleis a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type'help;' or '\h' for help. Type '\c'to clear the current input statement.
mysql>
修改密碼
mysql> SET PASSWORD FOR 'root'@localhost=PASSWORD('redhat');
Query OK,0 rows affected, 1 warning (0.01 sec)
設(shè)置主機(jī)可以遠(yuǎn)程登入
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'redhat'WITH GRANT OPTION;
Query OK,0 rows affected, 1 warning (0.00sec)
mysql> flush privileges; ==>刷新權(quán)限表
9.配置環(huán)境變量
[root@localhost local]# vim /etc/profile
# MySQL Environment Variable Settings
export MYSQL_HOME=/usr/local/mysql
export PATH=$PATH:$MYSQL_HOME/bin
[root@localhost local]# source/etc/profile
10.配置防火墻
[root@localhost local]# firewall-cmd --permanent --add-port=3306/tcp
success
[root@localhost local]# firewall-cmd --reload
success
安裝基本完成
總結(jié)
以上是生活随笔為你收集整理的redhat mysql tar_mysql5.7版本tar包手动安装---redhat7.0的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 三次握手和四次挥手图解_图解TCP三次握
- 下一篇: 扁桃体炎缺钾怎么治疗