MySQL在Windows和Linux平臺上多版本多例項安裝配置方法(5.5、5.6、5.7、8.0)
MySQL在Windows和Linux平臺上多版本多例項安裝配置方法(5.5、5.6、5.7、8.0)
Linux下MySQL 5.5、5.6和5.7的RPM、二進位制和原始碼安裝
參考:
http://blog.itpub.net/26736162/viewspace-2144261/
Windows下安裝MySQL
-------------------- Windows重新註冊 首先切換到MySQL的bin目錄下,執行如下命令: mysqld remove mysqld install ------Windows下解除安裝MySQL ① 關閉MySQL相關程式後並停止MySQL服務(services.msc) ② 命令列執行:sc delete mysql或mysqld remove ③ 刪除所有MySQL檔案 ④ regedit開啟登錄檔,刪除以下位置的3個資料夾: HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Eventlog\Application\MySQL HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Services\Eventlog\Application\MySQL HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application\MySQL ------Windows下安裝MySQL ------Windows下安裝MySQL:使用管理員許可權,已在windows 10、Windows7、XP上測試透過,XP不支援5.7及其以上版本 --建立服務時一定需要全路徑 --- 5.5、5.6、5.7、8.0 預設密碼都為空,8.0資料庫需要8.0的客戶端才能無密碼登入 D:\Program_Files\MySQL\mysql-8.0.15-winx64\bin\mysqld --initialize-insecure --user=mysql --console --basedir=D:\Program_Files\MySQL\mysql-8.0.15-winx64 --datadir=D:\Program_Files\MySQL\mysql-8.0.15-winx64\data803314 D:\Program_Files\MySQL\mysql-8.0.15-winx64\bin\mysqld install mysql803314 --defaults-file="D:\Program_Files\MySQL\mysql-8.0.15-winx64\mysql803314.ini" ---或直接安裝 mysqld --initialize-insecure mysqld install mysql573306 net start mysql573311 mysql -uroot -p -P3308 --5.5、5.6、5.7修改密碼和允許遠端登陸 update mysql.user set Host='%' where Host='127.0.0.1'; --update mysql.user set Host="%" where Host="localhost"; update mysql.user set password=password('lhr') where user='root'; update mysql.user set authentication_string=password('lhr') where user='root'; set password=password('lhr'); grant all privileges on *.* to root@'%' identified by 'lhr' WITH GRANT OPTION; flush privileges; select user,host,grant_priv,super_priv from mysql.user; --8.0修改密碼和允許遠端登陸 create USER 'root'@'%' identified by 'lhr'; ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'lhr'; ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'lhr'; grant all on *.* to root@'%' WITH GRANT OPTION; grant all on *.* to root@'localhost' WITH GRANT OPTION; flush privileges; select user,host,grant_priv,super_priv,authentication_string,password_last_changed from mysql.user; --mysql 8.0遠端連線,在引數檔案的[mysqld]下新增: default_authentication_plugin=mysql_native_password
---同版本安裝多例項 1、複製源庫的data資料夾為data3307,刪除裡邊的業務資料庫,對於5.6版本需要保留預設資料庫mysql、performance_schema、test,對於5.7和8.0版本需要所有資料庫都刪除 2、複製源庫的my.ini檔案到data3307目錄下命名my3307.ini,並修改相關引數:basedir、datadir、port等 2、初始化: D:\Program_Files\MySQL\mysql-8.0.15-winx64\bin\mysqld --initialize-insecure --user=mysql --basedir=D:\Program_Files\MySQL\mysql-8.0.15-winx64 --datadir=D:\Program_Files\MySQL\mysql-8.0.15-winx64\data3307 3、安裝服務: D:\Program_Files\MySQL\mysql-8.0.15-winx64\bin\mysqld install mysql563307 --defaults-file="D:\Program_Files\MySQL\mysql-8.0.15-winx64\data3307\my3307.ini" 注意: 1、可以不複製源軟體為新的資料夾。當然也可以複製一份全新的環境。 2、每個例項的配置檔案必須是單獨的。 --給mysql的root %使用者新增grant許可權。並給建立的使用者賦予許可權 select user,host,grant_priv,super_priv from mysql.user; update mysql.user set grant_priv='Y',super_priv='Y' where user='root'; flush privileges; show grants for 'root'@'%'; GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'lhr' WITH GRANT OPTION; ----------------my3307.ini引數檔案內容 [mysqld] port = 3313 basedir=D:\Program_Files\MySQL\mysql-8.0.15-winx64 datadir=D:\Program_Files\MySQL\mysql-8.0.15-winx64\data tasklist | findstr mysql
Linux下MySQL安裝
tar -zxvf mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz -C /usr/local/mysql57 mv mysql-5.7.19-linux-glibc2.12-x86_64 mysql5719 -- tar -Jxf mysql-8.0.16-linux-glibc2.12-x86_64.tar.xz -- mv mysql-8.0.16-linux-glibc2.12-x86_64 /usr/local/mysql80/mysql8016 groupadd mysql ## 新增一個mysql組 useradd -r -g mysql mysql ## 新增一個使用者 useradd -r -s /sbin/nologin -g mysql mysql -d /usr/local/mysql #新建msyql使用者禁止登入shell chown -R mysql.mysql /usr/local/mysql57 --- 5.5、5.6 --MySQL 5.5、5.6的二進位制安裝預設密碼為空 ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql55/mysql5557 --datadir=/usr/local/mysql55/mysql5557/data --defaults-file=/usr/local/mysql55/mysql5557/mysql55573310.cnf ./bin/mysqld_safe --defaults-file=/usr/local/mysql55/mysql5557/mysql55573310.cnf & --MySQL 5.7.6之後的版本初始化資料庫不再使用mysql_install_db ./bin/mysqld --defaults-file=/usr/local/mysql57/mysql5719/mysql57193308.cnf --initialize-insecure --user=mysql --basedir=/usr/local/mysql57/mysql5719 --datadir=/usr/local/mysql57/mysql5719/data ./bin/mysqld_safe --defaults-file=/usr/local/mysql57/mysql5719/mysql57193308.cnf & --Linux下同一個版本新建多個例項,和普通安裝一樣,重新設定配置檔案和data檔案、埠號 cp mysql57193308.cnf mysql57193309.cnf ./bin/mysqld --defaults-file=/usr/local/mysql57/mysql5719/mysql57193308.cnf --initialize-insecure --user=mysql --basedir=/usr/local/mysql57/mysql5719 --datadir=/usr/local/mysql57/mysql5719/data57193309 ./bin/mysqld_safe --defaults-file=/usr/local/mysql57/mysql5719/mysql57193309.cnf & ---5.5、5.6、5.7修改密碼和允許遠端登陸 ---連線: mysql -uroot -p -S/usr/local/mysql55/mysql5557/data/mysql55573310.sock set password=password("lhr"); --delete from mysql.user where Host='localhost' and user='root'; grant all privileges on *.* to root@'%' identified by 'lhr' WITH GRANT OPTION; flush privileges; --8.0修改密碼和允許遠端登陸 update mysql.user set Host="%" where Host="localhost"; update mysql.user set authentication_string='' where user='root'; ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'lhr'; -- 多執行幾次 ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'lhr'; flush privileges; select user,host,grant_priv,super_priv from mysql.user; --mysql 8.0遠端連線,在引數檔案的[mysqld]下新增: default_authentication_plugin=mysql_native_password ----------------mysql57193308.cnf引數檔案內容 [mysqld] port=3308 basedir=/usr/local/mysql57/mysql5719 datadir=/usr/local/mysql57/mysql5719/data socket=/usr/local/mysql57/mysql5719/data/mysql57193308.sock server_id=57193308 log-bin --配置開機啟動,不適合多例項情況 cp ./support-files/mysql.server /etc/init.d/mysql57193308 chmod 755 /etc/init.d/mysql57193308 chkconfig --add mysql57193308 chkconfig mysql57193308 on chkconfig --level 345 mysql57193308 on service mysql57193308 start ---Linux啟動MySQL /usr/local/mysql55/mysql5557/bin/mysqld_safe --defaults-file=/usr/local/mysql55/mysql5557/mysql55573310.cnf & /usr/local/mysql55/mysql5557/bin/mysqld_safe --defaults-file=/usr/local/mysql55/mysql5557/mysql55573311.cnf & /usr/local/mysql56/mysql5637/bin/mysqld_safe --defaults-file=/usr/local/mysql56/mysql5637/mysql56373312.cnf & /usr/local/mysql56/mysql5637/bin/mysqld_safe --defaults-file=/usr/local/mysql56/mysql5637/mysql56373313.cnf & /usr/local/mysql57/mysql5719/bin/mysqld_safe --defaults-file=/usr/local/mysql57/mysql5719/mysql57193308.cnf & /usr/local/mysql57/mysql5719/bin/mysqld_safe --defaults-file=/usr/local/mysql57/mysql5719/mysql57193309.cnf & /usr/local/mysql80/mysql8016/bin/mysqld_safe --defaults-file=/usr/local/mysql80/mysql8016/mysql80163314.cnf & /usr/local/mysql80/mysql8016/bin/mysqld_safe --defaults-file=/usr/local/mysql80/mysql8016/mysql80163315.cnf & ---Linux關閉MySQL /usr/local/mysql55/mysql5557/bin/mysqladmin -u root -plhr -S/usr/local/mysql55/mysql5557/data/mysql55573310.sock shutdown /usr/local/mysql55/mysql5557/bin/mysqladmin -u root -plhr -S/usr/local/mysql55/mysql5557/data55573311/mysql55573311.sock shutdown /usr/local/mysql56/mysql5637/bin/mysqladmin -u root -plhr -S/usr/local/mysql56/mysql5637/data/mysql56373312.sock shutdown /usr/local/mysql56/mysql5637/bin/mysqladmin -u root -plhr -S/usr/local/mysql56/mysql5637/data56373313/mysql56373313.sock shutdown /usr/local/mysql57/mysql5719/bin/mysqladmin -u root -plhr -S/usr/local/mysql57/mysql5719/data/mysql57193308.sock shutdown /usr/local/mysql57/mysql5719/bin/mysqladmin -u root -plhr -S/usr/local/mysql57/mysql5719/data57193309/mysql57193309.sock shutdown /usr/local/mysql80/mysql8016/bin/mysqladmin -u root -plhr -S/usr/local/mysql80/mysql8016/data/mysql80163314.sock shutdown /usr/local/mysql80/mysql8016/bin/mysqladmin -u root -plhr -S/usr/local/mysql80/mysql8016/data80163315/mysql80163315.sock shutdown 啟動全部例項:mysqld_multi start 檢視全部例項狀態:mysqld_multi report 啟動單個例項:mysqld_multi start 3306 停止單個例項:mysqld_multi stop 3306 檢視單個例項狀態:mysqld_multi report 3306 ---------------------- /etc/my.cnf 管理多例項 [mysqld_multi] mysqld=/usr/local/mysql80/mysql8016/bin/mysqld_safe mysqladmin=/usr/local/mysql80/mysql8016/bin/mysqladmin log=/usr/local/mysql80/log/mysqld_multi.log user=root password=lhr [client] port=3308 socket=/usr/local/mysql57/mysql5719/data/mysql57193308.sock user=root host=localhost password=lhr [mysql] default-character-set=utf8 [mysqld56213306] mysqld=/usr/local/mysql55/mysql5557/bin/mysqld_safe mysqladmin=/usr/local/mysql55/mysql5557/bin/mysqladmin log-bin basedir=/usr datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql slow_query_log=1 slow_query_log_file=/var/lib/mysql/rhel6lhr-slow.log [mysqld55573310] mysqld=/usr/local/mysql55/mysql5557/bin/mysqld_safe mysqladmin=/usr/local/mysql55/mysql5557/bin/mysqladmin port=3310 basedir=/usr/local/mysql55/mysql5557 datadir=/usr/local/mysql55/mysql5557/data socket=/usr/local/mysql55/mysql5557/data/mysql55573310.sock server_id=55573310 log-bin [mysqld55573311] mysqld=/usr/local/mysql55/mysql5557/bin/mysqld_safe mysqladmin=/usr/local/mysql55/mysql5557/bin/mysqladmin port=3311 basedir=/usr/local/mysql55/mysql5557 datadir=/usr/local/mysql55/mysql5557/data55573311 socket=/usr/local/mysql55/mysql5557/data55573311/mysql55573311.sock server_id=55573311 log-bin [mysqld56373312] mysqld=/usr/local/mysql56/mysql5637/bin/mysqld_safe mysqladmin=/usr/local/mysql56/mysql5637/bin/mysqladmin port=3312 basedir=/usr/local/mysql56/mysql5637 datadir=/usr/local/mysql56/mysql5637/data socket=/usr/local/mysql56/mysql5637/data/mysql56373312.sock server_id=56373312 log-bin [mysqld56373313] mysqld=/usr/local/mysql56/mysql5637/bin/mysqld_safe mysqladmin=/usr/local/mysql56/mysql5637/bin/mysqladmin port=3313 basedir=/usr/local/mysql56/mysql5637 datadir=/usr/local/mysql56/mysql5637/data56373313 socket=/usr/local/mysql56/mysql5637/data56373313/mysql56373313.sock server_id=56373313 log-bin [mysqld57193308] mysqld=/usr/local/mysql57/mysql5719/bin/mysqld_safe mysqladmin=/usr/local/mysql57/mysql5719/bin/mysqladmin port=3308 basedir=/usr/local/mysql57/mysql5719 datadir=/usr/local/mysql57/mysql5719/data socket=/usr/local/mysql57/mysql5719/data/mysql57193308.sock server_id=57193308 log-bin [mysqld57193309] mysqld=/usr/local/mysql57/mysql5719/bin/mysqld_safe mysqladmin=/usr/local/mysql57/mysql5719/bin/mysqladmin port=3309 basedir=/usr/local/mysql57/mysql5719 datadir=/usr/local/mysql57/mysql5719/data57193309 socket=/usr/local/mysql57/mysql5719/data57193309/mysql57193309.sock server_id=57193309 log-bin [mysqld80163314] mysqld=/usr/local/mysql80/mysql8016/bin/mysqld_safe mysqladmin=/usr/local/mysql80/mysql8016/bin/mysqladmin port=3314 basedir=/usr/local/mysql80/mysql8016 datadir=/usr/local/mysql80/mysql8016/data socket=/usr/local/mysql80/mysql8016/data/mysql80163314.sock default_authentication_plugin=mysql_native_password server_id=80163314 log-bin [mysqld80163315] mysqld=/usr/local/mysql80/mysql8016/bin/mysqld_safe mysqladmin=/usr/local/mysql80/mysql8016/bin/mysqladmin port=3315 basedir=/usr/local/mysql80/mysql8016 datadir=/usr/local/mysql80/mysql8016/data80163315 socket=/usr/local/mysql80/mysql8016/data80163315/mysql80163315.sock default_authentication_plugin=mysql_native_password server_id=80163315 log-bin
Windows重新註冊
首先切換到MySQL的bin目錄下,執行如下命令: mysqld remove mysqld install ------Windows下解除安裝MySQL ① 關閉MySQL相關程式後並停止MySQL服務(services.msc) ② 命令列執行:sc delete mysql或mysqld remove ③ 刪除所有MySQL檔案 ④ regedit開啟登錄檔,刪除以下位置的3個資料夾: HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Eventlog\Application\MySQL HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Services\Eventlog\Application\MySQL HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application\MySQL
MySQL命令:
檢視錯誤: perror 錯誤號 Oracle為oerr ora 01555 mysql -uroot -h192.168.59.130 -plhr mysql -uroot -h192.168.59.130 -P3306 -plhr mysql --html -t -f --silent < mysql_check_lhr_v1.3.0.sql mysql -h192.168.1.63 -uroot -plhr -P3306 --html -t -f --silent < mysql_check_lhr_v1.3.0.sql ---修改提示符 export MYSQL_PS1="(\u@\h) [\d]> " prompt (\u@\h) [\d]> prompt (\u@\h) [\d]>\_ prompt (\U) [\d]>\_ prompt \u@\d>\_ prompt \R:\m:\s>\_ prompt (\u@\h) [\d] \R:\m:\s>\_ [oracle@edsir1p8-EMREP ~]$ more .bashrc # .bashrc # User specific aliases and functions # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi export PS1="[\u@\h-\`echo \$ORACLE_SID\` \W]$ " --殺死mysql killall mysqld
About Me
........................................................................................................................ ● 本文作者:小麥苗,部分內容整理自網路,若有侵權請聯絡小麥苗刪除 ● 本文在itpub( http://blog.itpub.net/26736162)、部落格園( http://www.cnblogs.com/lhrbest)和個人微 信公眾號( xiaomaimiaolhr)上有同步更新 ● 本文itpub地址: http://blog.itpub.net/26736162 ● 本文部落格園地址: http://www.cnblogs.com/lhrbest ● 本文pdf版、個人簡介及小麥苗雲盤地址: http://blog.itpub.net/26736162/viewspace-1624453/ ● 資料庫筆試面試題庫及解答: http://blog.itpub.net/26736162/viewspace-2134706/ ● DBA寶典今日頭條號地址: ........................................................................................................................ ● QQ群號: 230161599(滿) 、618766405 ● 微 信群:可加我微 信,我拉大家進群,非誠勿擾 ● 聯絡我請加QQ好友 ( 646634621 ),註明新增緣由 ● 於 2019-07-01 06:00 ~ 2019-07-31 24:00 在西安完成 ● 最新修改時間:2019-07-01 06:00 ~ 2020-02-16 24:00 ● 文章內容來源於小麥苗的學習筆記,部分整理自網路,若有侵權或不當之處還請諒解 ● 版權所有,歡迎分享本文,轉載請保留出處 ........................................................................................................................ ● 小麥苗的微店: ● 小麥苗出版的資料庫類叢書: http://blog.itpub.net/26736162/viewspace-2142121/ ● 小麥苗OCP、OCM、高可用網路班: http://blog.itpub.net/26736162/viewspace-2148098/ ● 小麥苗騰訊課堂主頁: https://lhr.ke.qq.com/ ........................................................................................................................ 使用 微 信客戶端掃描下面的二維碼來關注小麥苗的微 信公眾號( xiaomaimiaolhr)及QQ群(DBA寶典)、新增小麥苗微 信, 學習最實用的資料庫技術。
........................................................................................................................ |
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26736162/viewspace-2651051/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- mysql 5.7 多例項安裝MySql
- Windows平臺下安裝與配置MySQL5.7WindowsMySql
- MySQL在Windows上安裝多個例項的方法MySqlWindows
- windows同時安裝 5.7 8.0 mysqlWindowsMySql
- 【MySQL】Linux下MySQL 5.5、5.6和5.7的RPM、二進位制和原始碼安裝MySqlLinux原始碼
- mysql5.6以上(適用5.7)免安裝版本 終極配置MySql
- Windows下PHP 5.6+Apache 2.4+MySQL 5.5安裝與配置WindowsPHPApacheMySql
- Windows 安裝並配置 MySQL 5.6WindowsMySql
- MySQL5.7 多例項MySql
- 在linux(Centos 7以上版本親測)上安裝mysql5.6LinuxCentOSMySql
- Mysql5.7 windows免安裝版本 初始化配置MySqlWindows
- mysql多例項安裝MySql
- windows安裝及配置mysql5.7WindowsMySql
- MySQL 5.6同一物理主機配置多例項MySql
- MySQL 5.6, 5.7, 8.0版本的新特性彙總大全MySql
- Windows 安裝 MySQL 5.6WindowsMySql
- mysql多版本例項安裝MySql
- linux mysql5.6版本的安裝配置過程LinuxMySql
- 在Windows 和Mac平臺上破解安裝Flash Builder 4WindowsMacUI
- PHP1:在Windows上安裝和配置PHP,Apache和MySQLPHPWindowsApacheMySql
- Windows平臺RTMP多例項推送探討Windows
- MySQL多例項配置MySql
- Linux上yum安裝mysql5.6LinuxMySql
- Windows平臺上使用noinstall方式部署MySQL 8.0WindowsMySql
- Windows平臺下安裝與配置MySQL9WindowsMySql
- mysql 在windows上安裝MySqlWindows
- Linux平臺(CentOS 6.5) RPM包方式安裝 Mysql 5.7LinuxCentOSMySql
- Linux下MySQL配置單機多例項LinuxMySql
- mysql的多例項配置MySql
- MySQL單機多例項安裝並配置主從複製MySql
- 在centos7上安裝mysql5.7CentOSMySql
- mysql在linux上cmake安裝方法(自己安裝版)MySqlLinux
- mysql5.7GroupReplication多主模式在Centos7.2上安裝部署MySql模式CentOS
- Linux 安裝 mysql 5.5.8(cmake原始碼安裝mysql5.5以上版本)[轉]LinuxMySql原始碼
- mysql-5.7.xx在lcentos7下的安裝以及mysql在windows以及linux上的效能差異MySqlCentOSWindowsLinux
- mysql-5.7在windows7下安裝和vs2013下的配置MySqlWindows
- linux下編譯安裝mysql5.5以上版本Linux編譯MySql
- MySQL介紹及安裝與多例項MySql