侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 130555 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

通过 MySQL 8.0 二进制安装包部署多实例

2024-05-16 星期四 / 0 评论 / 0 点赞 / 99 阅读 / 2248 字

解压安装包cd /usr/localtar xvf mysql-8.0.12-linux-glibc2.12-x86_64.tar.xzmv mysql-8.0.12-linux-glibc2.12-

解压安装包

cd /usr/localtar xvf mysql-8.0.12-linux-glibc2.12-x86_64.tar.xzmv mysql-8.0.12-linux-glibc2.12-x86_64 mysqlcd mysql/mkdir confexport PATH=$PATH:/usr/local/mysql/bin

实例1配置文件 my00.cnf

[mysqld]basedir=/usr/local/mysqldatadir=/var/lib/mysql00socket=/tmp/mysql00.socksymbolic-links=0port=3306mysqlx_port=33060[mysqld_safe]log-error=/var/log/mysqld00.logpid-file=/var/lib/mysql00/mysqld.pid

实例2配置文件 my01.cnf

[mysqld]basedir=/usr/local/mysqldatadir=/var/lib/mysql01socket=/tmp/mysql01.socksymbolic-links=0port=3307mysqlx_port=33070[mysqld_safe]log-error=/var/log/mysqld01.logpid-file=/var/lib/mysql01/mysqld.pid

实例3配置文件 my02.cnf

[mysqld]basedir=/usr/local/mysqldatadir=/var/lib/mysql02socket=/tmp/mysql02.socksymbolic-links=0port=3308mysqlx_port=33080[mysqld_safe]log-error=/var/log/mysqld02.logpid-file=/var/lib/mysql02/mysqld.pid

初始化实例

mysqld --defaults-file=/usr/local/mysql/conf/my00.cnf --initialize --user=mysqlmysqld --defaults-file=/usr/local/mysql/conf/my01.cnf --initialize --user=mysqlmysqld --defaults-file=/usr/local/mysql/conf/my02.cnf --initialize --user=mysql

启动实例

mysqld_safe --defaults-file=/usr/local/mysql/conf/my00.cnf --user=mysql &mysqld_safe --defaults-file=/usr/local/mysql/conf/my01.cnf --user=mysql &mysqld_safe --defaults-file=/usr/local/mysql/conf/my02.cnf --user=mysql &

修改密码

mysql -S /tmp/mysql00.sock -u root -pALTER USER root@'localhost' IDENTIFIED BY 'MySQL8.0';mysql -S /tmp/mysql01.sock -u root -pALTER USER root@'localhost' IDENTIFIED BY 'MySQL8.0';mysql -S /tmp/mysql02.sock -u root -pALTER USER root@'localhost' IDENTIFIED BY 'MySQL8.0';

关闭实例

mysqladmin -S /tmp/mysql00.sock -u root -pMySQL8.0 shutdownmysqladmin -S /tmp/mysql01.sock -u root -pMySQL8.0 shutdownmysqladmin -S /tmp/mysql02.sock -u root -pMySQL8.0 shutdown

注意:账号 root@'locahost' 使用 socket 连接数据库

参考文档:在Unix上运行多个MySQL实例

广告 广告

评论区