大家好,我是考100分的小小码 ,祝大家学习进步,加薪顺利呀。今天说一说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/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
代码100分
三、配置并安装
1) vim /etc/my.cnf # 将下面内容粘贴到里面
代码100分
[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)启动数据库
代码100分
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 实例
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
转载请注明出处: https://daima100.com/7767.html