mysql多实例安装
短信预约 信息系统项目管理师 报名、考试、查分时间动态提醒
一、下载
1)打开https://dev.mysql.com/downloads/mysql/
2)选择 Linux - Generic
3)下载 (mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz)
二、解压
# cd /usr/local/class="lazy" data-src
# wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz
# xz -d mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz && tar jxf mysql-8.0.20-linux-glibc2.12-x86_64.tar
三、配置并安装
1) vim /etc/my.cnf # 将下面内容粘贴到里面
[client]
port=3306
socket=/tmp/mysql.sock
[mysqld_multi]
mysqld = /usr/local/mysql/bin/mysqld_safe
mysqladmin = /usr/local/mysql/bin/mysqladmin
log = /mysql_data/mysqld_multi.log
[mysqld]
user=mysql
basedir = /usr/local/mysql
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysqld3306]
datadir=/mysql_data/data3306
port=3306
server_id=3306
socket=/tmp/data3306.sock
log-output=file
slow_query_log = 1
long_query_time = 1
slow_query_log_file = /mysql_data/data3306/slow.log
log-error = /mysql_data/data3306/error.log
binlog_format = mixed
log-bin = /mysql_data/data3306/mysql3306_bin
[mysqld3307]
mysqld=mysqld
mysqladmin=mysqladmin
datadir=/mysql_data/data3307
port=3307
server_id=3307
socket=/tmp/data3307.sock
log-output=file
slow_query_log = 1
long_query_time = 1
slow_query_log_file = /mysql_data/data3307/slow.log
log-error = /mysql_data/data3307/error.log
binlog_format = mixed
log-bin = /mysql_data/data3307/mysql3307_bin
2)初始化数据表
# 准备数据目录
mkdir /mysql_data/{data3306,data3307}
chown -R mysql.mysql /mysql_data
/usr/local/mysql/bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/mysql_data/data3306 --initialize
/usr/local/mysql/bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/mysql_data/data3307 --initialize
注意:这期间会产生密码,纪录下来
3)启动数据库
mysqld_multi start 3306
mysqld_multi start 3307
# 确保已经运行
# mysqld_multi report
Reporting MySQL servers
MySQL server from group: mysqld3306 is running
MySQL server from group: mysqld3307 is running
4)登录
mysql -uroot -S套接字地址 -p"密码"
# 如果希望使用端口号登录
# cd ~
# vim .my.cnf #内容如下
[client]
host=127.0.0.1
5)修改密码
# flush privileges; # 修改密码不成功报错时先执行它
# mysql -S/tmp/data3306.sock -p"密码"
# ALTER USER "root"@"localhost" IDENTIFIED WITH MYSQL_NATIVE_PASSWORD BY "新密码";
# flush privileges;
6)停止
# 实例 为 3306 和 3307
mysqld_multi --user=root --password="密码" stop 实例
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341