溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

RHEL 6.7利用rpm完整包安裝MySQL-5.6.30

發(fā)布時(shí)間:2020-08-13 08:11:39 來源:ITPUB博客 閱讀:144 作者:luashin 欄目:MySQL數(shù)據(jù)庫
利用rpm完整包安裝MySQL(MySQL-server-5.6.30 for rhel 6.7_64bit)
一、檢查操作系統(tǒng)上是否安裝了MySQL
[root@mydb1 backup]# rpm -qa |grep mysql
qt-mysql-4.6.2-26.el6_4.x86_64
mysql-5.1.71-1.el6.x86_64
mysql-server-5.1.71-1.el6.x86_64
mysql-devel-5.1.71-1.el6.x86_64
mysql-libs-5.1.71-1.el6.x86_64

二、刪除MyQL(RedHat6.7服務(wù)器自帶的mysql-libs是mysql-libs-5.1.61-4.el6.x86_64,可能會(huì)和高版本的mysql-libs有沖突)

[root@mydb1 backup]# rpm -qa |grep mysql*

[root@mydb1 backup]# yum -y remove mysql-libs-5.1.73-5.el6_6.x86_64


三、RPM安裝MySQL(用root用戶安裝,不需要提前建mysql組和mysql用戶,安裝mysql-server過程中會(huì)自動(dòng)創(chuàng)建)

MySQL-6.30 Yum Repository

rhel6

http://repo.mysql.com//mysql57-community-release-el6-8.noarch.rpm

rhel7

http://repo.mysql.com//mysql57-community-release-el7-8.noarch.rpm

MySQL Yum源官方說明:

http://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en

# Enable to use MySQL 5.7

[mysql57-community]

name=MySQL 5.7 Community Server

baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql


# Enable to use MySQL 5.6

[mysql56-community]

name=MySQL 5.6 Community Server

baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql


下載rpm完整包安裝MySQL

[root@mydb1 backup]# wget http://cdn.mysql.com//Downloads/MySQL-5.6/MySQL-5.6.30-1.el6.x86_64.rpm-bundle.tar

[root@mydb1 backup]# tar -xvf MySQL-5.6.30-1.el6.x86_64.rpm-bundle.tar

[root@mydb1 backup]# rpm -pql MySQL-server-5.6.23-1.el6.x86_64.rpm | more 
[root@mydb1 backup]# rpm -ivh MySQL-server-5.6.30-1.el6.i686.rpm
[root@mydb1 backup]# rpm -ivh MySQL-client-5.6.30-1.el6.x86_64.rpm
or
[root@mydb1 backup]# yum -y install MySQL-server* MySQL-client*


四、創(chuàng)建安裝目錄
[root@mydb1 backup]# mkdir -p /u01/app/mysql/data/mysql3306/{data,log,iblog,binlog,tmp}

五、配置my.cnf
[root@wmserpmysql1 ~]# cp -v /usr/my.cnf /u01/app/mysql/data/mysql3306/my.cnf
[root@wmserpmysql1 ~]# vim /u01/app/mysql/data/mysql3306/my.cnf
[client]
port=3306
socket=/u01/app/mysql/data/mysql3306/run/mysql.sock

[mysql]
port=3306
promprt=\\u@\\d \\r:\\m:\\s>

[mysqld]
default-storage-engine=INNODB
character-set-server=utf8
explicit_defaults_for_timestamp=true
#dir
basedir=/usr
datadir=/u01/app/mysql/data/mysql3306/data
tmpdir=/u01/app/mysql/data/mysql3306/tmp

innodb_log_group_home_dir=/u01/app/mysql/log/mysql3306/iblog
innodb_data_home_dir=/u01/app/mysql/log/mysql3306/iblog
slave_load_tmpdir=/u01/app/mysql/data/mysql3306/tmp
log-error=/u01/app/mysql/data/mysql3306/log/alert.log
slow_query_log_file=/u01/app/mysql/data/mysql3306/log/slow.log
relay_log_info_file=/u01/app/mysql/log/mysql3306/binlog/relay-log.info
master-info-file=/u01/app/mysql/log/mysql3306/binlog/master.info
socket=/u01/app/mysql/data/mysql3306/run/mysql.sock
log-bin=/u01/app/mysql/log/mysql3306/binlog/binlog
relay-log=/u01/app/mysql/log/mysql3306/binlog/relaylog
innodb_force_recovery=0

六、執(zhí)行MySQL安裝腳本
[root@wmserpmysql1 ~]# sh init3306.sh
rm -rf /u01/app/mysql/mysql3306/data/*
rm -rf /u01/app/mysql/log/mysql3306/iblog/*
rm -rf /u01/app/mysql/log/mysql3306/binlog/*
chmod -R 777 /u01/app/mysql/data/mysql/3306/data/*
chmod -R 777 /u01/app/mysql/log/mysql3306/iblog/*
chmod -R 777 /u01/app/mysql/log/mysql3306/binlog/*
chmod 755 /u01/app/mysql/data/mysql3306/my.cnf
mysql_install_db --defaults-file=/u01/app/mysql/data/mysql3306/my.cnf --basedir=/usr/ --datadir=/u01/app/mysql/data/mysql3306/data

七、查是否有MySQL服務(wù),如沒有添加mysql到服務(wù)開機(jī)啟動(dòng)
chkconfig --add mysqld
chkconfig --level 2345 mysqld on
查看開機(jī)啟動(dòng)設(shè)置是否成功
[root@mydb1 ~]# chkconfig --list | grep mysql
mysql          0:off  1:off  2:on    3:on    4:on    5:on    6:off

八、啟動(dòng)MySQL
[root@mydb1 ~]# service mysql start
Starting MySQL SUCCESS! 
 
九、查看MySQL運(yùn)行狀態(tài)的方法
[root@mydb1 ~]# service mysql status
SUCCESS! MySQL running (4104)
 
十、查MySQL初始密碼
[root@mydb1 ~]# cat /root/.mysql_secret 
# The random password set for the root user at Mon Mar 30 15:04:58 2015 (local time): B15xIBTq3xAoGRVx

十一、登錄MySQL
[root@mydb1 ~]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.6.23
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is 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> show databases;
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
mysql> SET PASSWORD = PASSWORD('guoyJoe123');
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)

使用root用戶進(jìn)行遠(yuǎn)程訪問
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'mysql' WITH GRANT OPTION;

十三、my.cnf參考:
MySQL系統(tǒng)參數(shù)配置
先不啟動(dòng)MySQL,拷貝數(shù)據(jù)目錄到新的位置/mysqldata,并修改權(quán)限
[root@wmserpmysql1 /]# cd /var/lib/mysql/
[root@wmserpmysql1 /]# cp -r * /mysqldata/
[root@wmserpmysql1 /]# chown mysql:mysql -R /mysqldata

刪除原來默認(rèn)的參數(shù)文件
[root@wmserpmysql1 mysql]# rm /usr/my.cnf
rm: remove regular file `/usr/my.cnf'? y 

重新拷貝新的參數(shù)文件,然后修改
[root@wmserpmysql1 mysql]# pwd
/usr/share/mysql
[root@wmserpmysql1 mysql]# cp my-default.cnf /etc/my.cnf
[root@wmserpmysql1 mysql]# vim /etc/my.cnf
修改參數(shù)文件/etc/my.cnf
[client]
port = 3306
socket = /tmp/mysql.sock

[mysql]
no-auto-rehash 

[mysqld]
port = 3306
socket = /tmp/mysql.sock
datadir=/mysqldata
skip-name-resolve
character-set-server=utf8
lower_case_table_names=1
expire-logs-days=60
back_log = 500
max_connections = 5000
max_connect_errors =100000
table_open_cache = 2048
max_allowed_packet = 16M
binlog_cache_size = 1M
max_heap_table_size = 64M
sort_buffer_size = 8M
join_buffer_size = 8M
thread_cache_size = 8
thread_concurrency =16
query_cache_size = 64M
query_cache_limit = 2M
ft_min_word_len = 4
thread_stack = 192K
tmp_table_size = 64M
log-bin=mysql-bin
binlog_format=mixed 
slow_query_log_file=/mysqldata/localhost-slow.log
slow_query_log
long_query_time=1
relay-log=/mysqldata/relay-bin
server-id = 1
key_buffer_size = 32M
myisam_repair_threads = 1
myisam_recover
transaction_isolation = REPEATABLE-READ
innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 10G
innodb_data_file_path = ibdata1:10M:autoextend
innodb_file_per_table=1
innodb_file_io_threads = 4
innodb_thread_concurrency = 16
innodb_flush_log_at_trx_commit = 1
innodb_log_buffer_size = 8M
innodb_log_file_size = 256M
innodb_log_files_in_group = 6
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
innodb_flush_method=O_DIRECT
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

[mysqldump]
quick
max_allowed_packet = 16M

[myisamchk]
key_buffer_size = 512M
sort_buffer_size = 512M
read_buffer = 8M
write_buffer = 8M

[mysqlhotcopy]
interactive-timeout

[mysqld_safe]
open-files-limit = 65535
log-error=/mysqldata/wmserpmysql1.800best.com.err
pid-file=/mysqldata/wmserpmysql1.800best.com.pid

十四、查看及設(shè)置連接狀態(tài)
MySQL的最大連接數(shù)默認(rèn)是100
客戶端登錄:
mysql -uusername -ppassword

設(shè)置新的最大連接數(shù)為200:
mysql> set GLOBAL max_connections=200
顯示當(dāng)前運(yùn)行的Query:
mysql> show processlist

顯示當(dāng)前狀態(tài):
mysql> show status;
退出客戶端:
mysql> exit

查看當(dāng)前最大連接數(shù):
mysqladmin -uusername -ppassword variables |find "max_con"
如:
C:\mysql\bin>mysqladmin -uroot -p variables | find "max_con"
Enter password:
| max_connections | 100
| max_connect_errors | 100

十五、查詢MySQL數(shù)據(jù)表的存儲(chǔ)引擎類型
提問: 想要知道MySQL數(shù)據(jù)庫是MyISAM還是Innodb類型。該如何檢查MySQL數(shù)據(jù)庫表的類型?
   MySQl使用的存儲(chǔ)引擎主要有兩種:MyISAM和Innodb。MyISAM是非事務(wù)的,因此擁有讀取更快,然而InnoDB完全支持細(xì)顆粒度的事務(wù)鎖定(比如:commit/rollback)。當(dāng)創(chuàng)建一張新的MySQL表時(shí),選擇它的類型(也就是存儲(chǔ)引擎)。如果沒有選擇,就會(huì)使用與預(yù)設(shè)置的默認(rèn)引擎。如果想要知道已經(jīng)存在的MySQL數(shù)據(jù)表的類型,以下幾種方法可以達(dá)到。
方法一
  訪問phpMyAdmin,從phpMyAdmin找出默認(rèn)的數(shù)據(jù)庫類型。從phpMyAdmin中選中數(shù)據(jù)庫來查看它的表列表。在“Type”一列的下面,將會(huì)看到每個(gè)表的數(shù)據(jù)表類型。
方法二
   可以直接登錄MySQL服務(wù)器,另外一種鑒別存儲(chǔ)引擎的方法是登錄MySQL服務(wù)器后運(yùn)行下面的MySQL命令:
mysql> SELECT ENGINE FROM information_schema.TABLES WHERE TABLE_SCHEMA ='my_database' AND TABLE_NAME ='my_table';
上面的命令會(huì)顯示在'mydatabase'數(shù)據(jù)庫中'mytable'表的引擎類型。
方法三
   還有一種檢查引擎的方法是使用mysqlshow,是一種命令行下的顯示數(shù)據(jù)庫信息的工具。mysqlshow在MySQL 客戶端安裝包中有。要使用mysqlshow,需要提供MySQL服務(wù)器登錄憑據(jù)。
下面的命令會(huì)顯示特定的數(shù)據(jù)庫信息。在“Engine”一列下面,可以看到每個(gè)表使用的引擎。
$ mysqlshow -u -p -i

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI