您好,登錄后才能下訂單哦!
本文主要給大家介紹MySQL5.6二進制包方式安裝流程講義,希望可以給大家補充和更新些知識,如有其它問題需要了解的可以持續(xù)在億速云行業(yè)資訊里面關注我的更新文章的。
MySQL基于二進制格式安裝的優(yōu)點在于,它是針對特定平臺專門優(yōu)化過的,安裝的時候也不需要考慮環(huán)境的要求,直接解壓就可以,本文基于MySQL5.6.38版本,下載地址為:
https://cdn.mysql.com//Downloads/MySQL-5.6/mysql-5.6.38-linux-glibc2.12-x86_64.tar.gz
1,下載MySQL二進制包:
[root@localhost ~]# mkdir /root/soft/ -pv
[root@localhost ~]# cd soft/
[root@localhost soft]# wget https://cdn.mysql.com//Downloads/MySQL-5.6/mysql-5.6.38-linux-glibc2.12-x86_64.tar.gz
2,解壓到/usr/local下:
[root@localhost soft]# tar xf mysql-5.6.38-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
3,創(chuàng)建軟鏈接:
[root@localhost soft]# cd /usr/local/
[root@localhost local]# ln -sv mysql-5.6.38-linux-glibc2.12-x86_64/ mysql
4,創(chuàng)建mysql數(shù)據(jù)目錄:
[root@localhost ~]# mkdir /data/mydata -pv
4,創(chuàng)建mysql用戶,mysql組,授權(quán)數(shù)據(jù)目錄:
[root@localhost ~]# groupadd -r mysql
[root@localhost ~]# useradd -r -g mysql -s /sbin/nologin -M -d /data/mydata mysql
[root@localhost ~]# chown -R mysql:mysql /data/mydata/
5,初始化數(shù)據(jù)庫:
[root@localhost ~]# cd /usr/local/mysql
[root@localhost mysql]# chown -R mysql.mysql .
[root@localhost mysql]# ./scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/data/mydata/ --user=mysql
FATAL ERROR: please install the following Perl modules before executing ./scripts/mysql_install_db:
Data::Dumper
這里出現(xiàn)一個報錯提示我有Perl模塊沒有裝,于是我照常安裝了perl-devel,perl等軟件包,再初始化數(shù)據(jù)發(fā)現(xiàn)還是報錯,搜索了下原來是perl-Data-Dumper.x86_64 0:2.145-3.el7這個包,報錯的信息提示的很明顯,好吧,下次一定好好看報錯信息。解決方法也很簡單,直接yum install即可。
[root@localhost mysql]# yum list perl-Data-Dumper
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.cn99.com
* extras: mirrors.cn99.com
* updates: centos.ustc.edu.cn
Available Packages
perl-Data-Dumper.x86_64
[root@localhost mysql]# yum install perl-Data-Dumper -y
再次執(zhí)行:
[root@localhost mysql]# ./scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/data/mydata/ --user=mysql
Installing MySQL system tables.../usr/local/mysql/bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
又一個報錯出現(xiàn),這個提示表明libaio這個模塊不存在,好,缺啥咱就裝啥。
[root@localhost mysql]# yum install libaio -y
然后再執(zhí)行mysql_install_db腳本初始化數(shù)據(jù)庫,這次沒有報錯,當看到OK字樣時,表示數(shù)據(jù)庫初始化完成。
6,設置mysql數(shù)據(jù)庫配置文件。這里要注意mysql5.6解壓目錄下的 support-files目錄中只有my-default.cnf這樣一個默認配置文件,而且里面基本沒有配置,多為注釋,這和mysql5.5的區(qū)別比較大,5.5的該目錄下會有 my-huge.cnf my-innodb-heavy-4G.cnf my-large.cnf my-medium.cnf my-small.cnf 這樣的配置文件,可以根據(jù)自身云服務器的情況自行選擇。既然如此,就只能自己配置my.cnf了。
[root@localhost ~]# vi /etc/my.cnf
[client]
#password = your_password
port = 3306
socket = /tmp/mysql.sock
[mysqld]
port = 3306
socket = /tmp/mysql.sock
#datadir = /usr/local/mysql/var
datadir = /data/mydata/
basedir = /usr/local/mysql/
pid-file = /data/mydata/mysql.pid
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
thread_cache_size = 8
query_cache_size = 8M
tmp_table_size = 16M
#skip-networking
max_connections = 500
max_connect_errors = 100
open_files_limit = 65535
log-bin=mysql-bin
binlog_format=mixed
server-id = 1
expire_logs_days = 10
default_storage_engine = InnoDB
innodb_file_per_table = 1
innodb_data_home_dir = /data/mydata/
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /data/mydata/
innodb_buffer_pool_size = 16M
innodb_additional_mem_pool_size = 2M
innodb_log_file_size = 5M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
7,導出PATH環(huán)境變量:
[root@localhost ~]# echo "export PATH=$PATH:/usr/local/mysql/bin" > /etc/profile.d/mysql.sh
[root@localhost ~]# . /etc/profile.d/mysql.sh
8,導出mysql頭文件到系統(tǒng)頭文件目錄:
[root@localhost ~]# ln -sv /usr/local/mysql/include /usr/include/mysql
9,輸出mysql庫文件到系統(tǒng)庫文件的路徑:
[root@localhost ~]# echo '/usr/local/mysql/lib' > /etc/ld.so.conf.d/mysql.conf
[root@localhost ~]# ldconfig -v
10,啟動mysqld服務:
[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[root@localhost mysql]# chkconfig mysqld on
[root@localhost mysql]# /etc/init.d/mysqld start
這里要注意一下,/etc/init.d/mysqld這個腳本中有如下幾個地方要修改:
basedir=/usr/local/mysql
datadir=/data/mydata/
mysqld_pid_file_path=/data/mydata/mysql.pid
這時候mysql就已經(jīng)啟動了:
[root@localhost mysql]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.6.38-log MySQL Community Server (GPL)
Copyright (c) 2000, 2017, 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> use mysql
Database changed
mysql> delete from mysql.user where (user,host) not in (select 'root', 'localhost'); #刪除多余的用戶
mysql> update user set password=password('QWER@@111') where user='root'; #修改root密碼
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select user,host,password from user;
+------+-----------+-------------------------------------------+
| user | host | password |
+------+-----------+-------------------------------------------+
| root | localhost | *16FF293CF039130E27DC275D8B47EBB0754FFE9F |
+------+-----------+-------------------------------------------+
1 row in set (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
至此,MySQL數(shù)據(jù)庫安裝完成。
看了以上關于MySQL5.6二進制包方式安裝流程講義,希望能給大家在實際運用中帶來一定的幫助。本文由于篇幅有限,難免會有不足和需要補充的地方,如有需要更加專業(yè)的解答,可在官網(wǎng)聯(lián)系我們的24小時售前售后,隨時幫您解答問題的。
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。