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:使用管理員許可權,已在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 authentication_string=password("lhr") where user="root"; update mysql.user set Host="%" where Host="127.0.0.1"; update mysql.user set Host="%" where Host="localhost"; set password=password('lhr'); grant all privileges on *.* to root@'%' identified by 'lhr'; 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'; -- 多執行幾次 flush privileges; select user,host from mysql.user; --mysql 8.0遠端連線,在引數檔案的[mysqld]下新增: default_authentication_plugin=mysql_native_password --mysql 8.0.15忘記密碼,修改密碼:http://blog.itpub.net/26736162/viewspace-2650907/ 1、停止服務 2、管理員許可權執行:D:\Program_Files\MySQL\mysql-8.0.15-winx64\bin\mysqld --defaults-file="D:\Program_Files\MySQL\mysql-8.0.15-winx64\mysql803314.ini" --console --skip-grant-tables --shared-memory 3、mysql -uroot -p -P3308 #無密碼登入 update mysql.user set authentication_string='' where user='root'; 4、退出,關閉第2步的console,重新空密碼登入 5、修改密碼:ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'lhr'; ----同版本安裝多例項 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、每個例項的配置檔案必須是單獨的。 ----------------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 & --同一個版本新建多個例項,和普通安裝一樣,重新設定配置檔案和data檔案、埠號 --- mysql -uroot -p -S/usr/local/mysql55/mysql5557/data/mysql55573310.sock 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修改密碼和允許遠端登陸 set password=password("lhr"); grant all privileges on *.* to root@'%' identified by 'lhr'; 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 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寶典今日頭條號地址: http://www.toutiao.com/c/user/6401772890/#mid=1564638659405826 ........................................................................................................................ ● QQ群號: 230161599 (滿) 、618766405 ● 微 信群:可加我微 信,我拉大家進群,非誠勿擾 ● 聯絡我請加QQ好友 ( 646634621 ) ,註明新增緣由 ● 於 2019-07-01 06:00 ~ 2019-07-31 24:00 在西安完成 ● 最新修改時間:2019-07-01 06:00 ~ 2019-07-31 24:00 ● 文章內容來源於小麥苗的學習筆記,部分整理自網路,若有侵權或不當之處還請諒解 ● 版權所有,歡迎分享本文,轉載請保留出處 ........................................................................................................................ ● 小麥苗的微店 : https://weidian.com/s/793741433?wfr=c&ifr=shopdetail ● 小麥苗出版的資料庫類叢書 : 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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Windows平臺下安裝與配置MySQL5.7WindowsMySql
- windows同時安裝 5.7 8.0 mysqlWindowsMySql
- Windows 安裝並配置 MySQL 5.6WindowsMySql
- 在linux(Centos 7以上版本親測)上安裝mysql5.6LinuxCentOSMySql
- MySQL5.7 多例項MySql
- mysql多例項安裝MySql
- Mysql5.7 windows免安裝版本 初始化配置MySqlWindows
- linux mysql5.6版本的安裝配置過程LinuxMySql
- windows安裝及配置mysql5.7WindowsMySql
- Linux上yum安裝mysql5.6LinuxMySql
- Windows 安裝 MySQL 5.6WindowsMySql
- MySQL 5.6, 5.7, 8.0版本的新特性彙總大全MySql
- mysql多版本例項安裝MySql
- MySQL多例項配置MySql
- Windows平臺RTMP多例項推送探討Windows
- Windows平臺上使用noinstall方式部署MySQL 8.0WindowsMySql
- Windows平臺下安裝與配置MySQL9WindowsMySql
- Linux安裝Mysql5.6LinuxMySql
- mysql在linux上cmake安裝方法(自己安裝版)MySqlLinux
- MariaDB在Linux和Windows上的安裝LinuxWindows
- Linux安裝mysql 8.0LinuxMySql
- mysql-5.7.xx在lcentos7下的安裝以及mysql在windows以及linux上的效能差異MySqlCentOSWindowsLinux
- MySQL介紹及安裝與多例項MySql
- Linux下安裝MySQL 5.7LinuxMySql
- Linux 7 安裝Mysql 5.7LinuxMySql
- 在centos7上安裝mysql5.7CentOSMySql
- 【Mysql】Windows下安裝和配置MysqlMySqlWindows
- Windows安裝MySQL5.7教程WindowsMySql
- Windows 和 Linux 上安裝 TTF 字型的方法WindowsLinux
- MySQL 多例項配置管理:MySql
- mysql5.7 for windows二進位制安裝及配置MySqlWindows
- Rocky Linux 安裝 MySQL 8.0LinuxMySql
- Linux安裝MySQL8.0LinuxMySql
- mysql5.7GroupReplication多主模式在Centos7.2上安裝部署MySql模式CentOS
- Windows 本地安裝 Mysql8.0WindowsMySql
- 通過Xshell6跳板機在Linux上安裝MySQL5.7LinuxMySql
- 技術分享 | 如何優雅地在 Windows 上從 MySQL 5.6 升級到 5.7WindowsMySql
- Ubuntu 18.04 安裝配置 MySQL 5.7UbuntuMySql