centos7 二進制安裝mysql 5.7.16版本

1下載解壓mysql安裝包
[root@localhost mysql]# tar xvf mysql-5.7.16-linux-glibc2.5-i686.tar.gz
對解壓的文件重命名
[root@localhost mysql]#mv mysql-5.7.16-linux-glibc2.5-i686 mysql-5.7.16
2我這裏在usr目錄下創建mysql文件夾
[root@master mysql]# pwd
/usr/mysql
3.[root@master mysql]# 在mysql目錄下創建 data,logs,pid文件夾
[root@master mysql]# ls
boost mysql5.7
data mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz
logs mysql-test-5.7.16-linux-glibc2.5-x86_64.tar.gz pids
4、創建mysql的用戶組和用戶,並對mysql目錄設置用戶組和用戶
[root@master mysql]# groupadd mysql
[root@master mysql]# useradd mysql -g mysql
5、添加用戶組權限
[root@localhost mysql]# chown -R mysql .
[root@localhost mysql]# chgrp -R mysql .
6、安裝mysql
[root@master mysql]# ls
mysql5.7
mysql-5.7.16 這是我解壓後重命名的名字
data mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz
logs mysql-test-5.7.16-linux-glibc2.5-x86_64.tar.gz
make pids
[root@master mysql]# cd mysql-5.7.16/
[root@master mysql-5.7.16]# ls
bin COPYING docs include lib man README share support-files
[root@master mysql-5.7.16]# cd bin/
[root@master bin]# ls
innochecksum mysql_config_editor mysqlshow
lz4_decompress mysqld mysqlslap
myisamchk mysqld-debug mysql_ssl_rsa_setup
myisam_ftdump mysqld_multi mysqltest_embedded
myisamlog mysqld_safe mysql_tzinfo_to_sql
myisampack mysqldump mysql_upgrade
my_print_defaults mysqldumpslow mysqlxtest
mysql mysql_embedded perror
mysqladmin mysqlimport replace
mysqlbinlog mysql_install_db resolveip
mysqlcheck mysql_plugin resolve_stack_dump
mysql_client_test_embedded mysqlpump zlib_decompress
mysql_config mysql_secure_installation
進入mysql源文件的bin目錄下執行 yum install libaio安裝插件
[root@master bin]# yum install libaio
執行命令
[root@master bin]# ./mysql_install_db –user=mysql –basedir=/usr/mysql/mysql5.7/ –datadir=/usr/mysql/data
注意:這個命令會報錯:
2017-06-15 13:49:16 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld –initialize
2017-06-15 13:49:18 [ERROR] The bootstrap log isn’t empty:
2017-06-15 13:49:18 [ERROR] 2017-06-15T05:49:16.141037Z 0 [Warning] –bootstrap is deprecated. Please consider using –initialize instead
2017-06-15T05:49:16.141501Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2017-06-15T05:49:16.141505Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)
2017-06-15T05:49:16.141678Z 0 [ERROR] Can’t read from messagefile ‘/usr/share/mysql/english/errmsg.sys’
這個錯誤原因:“”bootstrap is deprecated. Please consider using –initialize instead“”大致意思是啓動方式已經啓用:mysql_install_db。
在mysql官網得知新方式
./mysqld –user=mysql –basedir=/usr/mysql/mysql5.7/ –datadir=/usr/mysql/data
使用mysqld來啓動:
[root@master bin]# ./mysqld –initialize –user=mysql –basedir=/usr/mysql/mysql-5.7.16 –datadir=/usr/mysql/data
[root@master bin]# ./mysqld –initialize –user=mysql –basedir=/usr/mysql/mysql-5.7.16 –datadir=/usr/mysql/data
2017-06-15T07:37:19.261129Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use –explicit_defaults_for_timestamp server option (see documentation for more details).
2017-06-15T07:37:19.261176Z 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 in a future release.
2017-06-15T07:37:19.261180Z 0 [Warning] ‘NO_AUTO_CREATE_USER’ sql mode was not set.
2017-06-15T07:37:19.578311Z 0 [Warning] InnoDB: New log files created, LSN=45790
2017-06-15T07:37:19.641818Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-06-15T07:37:19.705611Z 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: 76730c2f-519d-11e7-b762-000c29629ecb.
2017-06-15T07:37:19.706501Z 0 [Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed’ cannot be opened.
2017-06-15T07:37:19.706935Z 1 [Note] A temporary password is generated for root@localhost: kkgeQvjh;2lV

臨時生成的密碼kkgeQvjh;2lV

以上步驟安裝成功
7、配置文件
[root@master mysql-5.7.16]# ls
bin COPYING docs include lib man README share support-files
[root@master mysql-5.7.16]# cd support-files/
[root@master support-files]# ls
`1 magic my-default.cnf mysqld_multi.server mysql-log-rotate mysql.server
[root@master support-files]# cp my-default.cnf /etc/my.cnf
cp:是否覆蓋”/etc/my.cnf”? yes
[root@master support-files]# cp mysql.server /etc/init.d/mysql
[root@master support-files]# vi /etc/i
idmapd.conf inputrc ipsec.conf iscsi/
init.d/ ipa/ ipsec.d/ issue
inittab iproute2/ ipsec.secrets issue.net
[root@master support-files]# vi /etc/init.d/mysql

basedir=/usr/mysql/mysql5.7/
datadir=/usr/mysql/data
8、配置環境變量
[root@master ~]# vi .bash_profile

.bash_profile

if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

PATH=PATH: HOME/bin

export MYSQL_HOME=”/usr/mysql/mysql-5.7.16”
export PATH=”PATH: MYSQL_HOME/bin”

9.添加開機啓動服務
chkconfig –add mysql
chkconfig mysql on

10。啓動報錯

啓動報錯了,原來是編輯/etc/init.d/mysql 文件出錯了,修改爲下面

vim /etc/init.d/mysql
basedir=/home/mysql/mysql-5.7.16
datadir=/home/mysql/data

修改之後

service mysql start

[root@master ~]# service mysql start
Starting MySQL. SUCCESS!
[root@master ~]#

[root@localhost mysql]#chkconfig –list mysqld

mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off

  1. 重啓系統,mysqld就會自動啓動了。

*檢查是否啓動

[root@localhost mysql]#netstat -anp|grep mysqld

tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2365/mysqld

unix 2 [ ACC ] STREAM LISTENING 14396 2365/mysqld /tmp/mysql.sock

12、修改密碼: ./mysqladmin -u root -p password “新密碼”
[root@master bin]# ./mysqladmin -u root -p password 123456
Enter password:
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
登錄
[root@master bin]# ./mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 24
Server version: 5.7.16 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, 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> GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘123456’ WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.00 sec)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章