程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> MYSQL數據庫 >> 關於MYSQL數據庫 >> ubuntu kylin 14.10下多個mysql 5.7.14安裝教程

ubuntu kylin 14.10下多個mysql 5.7.14安裝教程

編輯:關於MYSQL數據庫

前文已述,因為需要測試mysql的主從配置方案,所以要安裝多個mysql。這次是在ubuntu kylin 14.10上安裝多個mysql 5.7.14。

系統環境:ubuntu kylin 14.10,64位系統
mysql版本:5.7.14社區版
mysql下載地址:http://dev.mysql.com/downloads/mysql/,選擇 Linux - Generic,下載612.9M的mysql-5.7.14-linux-glibc2.5-x86_64.tar.gz
mysql官方安裝文檔:http://dev.mysql.com/doc/refman/5.7/en/binary-installation.html1.按照官方安裝文檔進行即可,只是一些shell命令做了修改,對ubuntu來說,大部分命令都需要在前面增加sudo

shell> sudo groupadd mysql
shell> sudo useradd -r -g mysql -s /bin/false mysql
shell> cd /usr/local
shell> sudo tar -zxvf /path/to/mysql-VERSION-OS.tar.gz

shell> sudo mv mysql-5.7.14-linux-glibc2.5-x86_64 mysql-5.7.14-linux-glibc2.5-x86_64-3306 #將mysql的目錄改了一下名
shell> sudo ln -s mysql-5.7.14-linux-glibc2.5-x86_64-3306 mysql-3306
shell> cd mysql-3306
shell> sudo mkdir mysql-files
shell> sudo chmod 750 mysql-files
shell> sudo chown -R mysql:mysql .
shell> sudo cp support-files/my-default.cnf ./my.cnf #copy一份my.cnf

接著編輯my.cnf,打開basedir,datadir,port等項,按如下配置:
basedir = /usr/local/mysql-3306
datadir = /usr/local/mysql-3306/data
port = 3306
server_id = 11

然後開始初始化3306端口上的mysql:
shell> sudo bin/mysqld --defaults-file=/usr/local/mysql-3306/my.cnf --initialize --user=mysql
2016-07-29T15:38:48.896585Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-07-29T15:38:48.896672Z 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.
2016-07-29T15:38:48.896682Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
2016-07-29T15:38:50.498675Z 0 [Warning] InnoDB: New log files created, LSN=45790
2016-07-29T15:38:50.890849Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-07-29T15:38:51.062752Z 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: 8c708a13-55a2-11e6-835e-a0481ced538c.
2016-07-29T15:38:51.088854Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2016-07-29T15:38:51.090179Z 1 [Note] A temporary password is generated for root@localhost: pJLwjf%q;1t)

shell> sudo bin/mysql_ssl_rsa_setup --defaults-file=/usr/local/mysql-3306/my.cnf
Generating a 2048 bit RSA private key
.........+++
.......................+++
writing new private key to 'ca-key.pem'
-----
Generating a 2048 bit RSA private key
..........+++
..............................................................+++
writing new private key to 'server-key.pem'
-----
Generating a 2048 bit RSA private key
................................................+++
........................................+++
writing new private key to 'client-key.pem'
-----

shell> sudo chown -R root .
shell> sudo chown -R mysql data mysql-files
shell> sudo bin/mysqld_safe --user=mysql & #啟動mysql,在後台運行
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server

2.開始登錄mysql進行相關操作

/usr/local/mysql-3306> bin/mysql -uroot -p
注意在執行bin/mysqld初始化時,在命令行最後的提示中給出了一個臨時口令,輸入之後即可登錄。登錄mysql之後,要求立即修改密碼,否則不能進行任何操作。執行下面的命令修改'root'@'localhost'的密碼:

mysql> SET PASSWORD = PASSWORD('your new password');
mysql> ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
mysql> flush privileges;

為了可以遠程登錄,增加一個'root'@'%'賬號:

復制代碼 代碼如下:mysql> grant all privileges on *.* to 'root'@'%' identified by 'your new password' with grant option;

3.按照上面的辦法,繼續解壓安裝mysql-5.7.14-linux-glibc2.5-x86_64.tar.gz,並且配置為3307,3308,3309端口,就可以安裝多個mysql了。

精彩專題分享:mysql不同版本安裝教程 mysql5.7各版本安裝教程

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持。

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved