这篇文章主要介绍多实例安装mysql 5.7的示例分析,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
datadir:mkdir -p /home/data/3306
mkdir -p /home/data/3307
mkdir -p /home/data/3308
chown -R mysql /home/data/
cd/opt/mysql
初始化mysql
./bin/mysqld –initialize –datadir=/home/data/3306 –user=mysql
./bin/mysqld –initialize –datadir=/home/data/3307 –user=mysql
./bin/mysqld –initialize –datadir=/home/data/3308 –user=mysql
启动mysql
bin/mysqld_safe –defaults-file=/opt/mysql/3306.cnf–user=mysql &
bin/mysqld_safe –defaults-file=/opt/mysql/3307.cnf–user=mysql &
bin/mysqld_safe –defaults-file=/opt/mysql/3308.cnf–user=mysql &
修改密码
注意:执行bin/mysqld –initialize的时候,日志会输出初始化的密码
关键字 A temporary password is generated for root@localhost:
mysql> set password = password(‘rootroot’);
mysql> flush privileges;
配置环境变量
vim /etc/profile 添加
export PATH=$PATH:/opt/mysql/bin
刷新环境变量
source /etc/profile
配置别名
vim /root/.bashrc
“`
alias mysql3306=’mysql -uroot -prootroot -P3306 –socket=/home/data/3306/mysql.sock’
alias start_mysql_3306=’/opt/mysql/bin/mysqld_safe –defaults-file=/opt/mysql/3306.cnf –user=mysql &’
alias stop_mysql_3306=’mysqladmin shutdown -uroot -p”rootroot” –socket=/home/data/3306/mysql.sock’
alias mysql3307=’mysql -uroot -prootroot -P3307 –socket=/home/data/3307/mysql.sock’
alias start_mysql_3307=’/opt/mysql/bin/mysqld_safe –defaults-file=/opt/mysql/3307.cnf –user=mysql &’
alias stop_mysql_3307=’mysqladmin shutdown -uroot -p”rootroot” –socket=/home/data/3307/mysql.sock’
alias mysql3308=’mysql -uroot -prootroot -P3308 –socket=/home/data/3308/mysql.sock’
alias start_mysql_3308=’/opt/mysql/bin/mysqld_safe –defaults-file=/opt/mysql/3308.cnf –user=mysql &’
alias stop_mysql_3308=’mysqladmin shutdown -uroot -p”rootroot” –socket=/home/data/3308/mysql.sock’
“`
建立主从
change master to
MASTER_HOST=”192.168.64.52″,
MASTER_USER=”root”,
MASTER_PASSWORD=”rootroot”,
MASTER_PORT=3306,
MASTER_CONNECT_RETRY=免费主机域名10,
MASTER_AUTO_POSITION = 1;
编辑/opt/mysql/3306.cnf
“`
[mysql]
prompt = “u@master R:m:s [d]> ”
[client]
port = 3306
socket = /data/mysql/data/mysql.sock
[mysqld]
datadir=/home/data/3306
socket=/home/data/3306/mysql.sock
skip-name-resolve
symbolic-links=0
log_bin = binlog
binlog_format= ROW
slow_query_log = 1
slow_query_log_file = slow.log
log-error = error.log
innodb_buffer_pool_size =512MB
innodb_buffer_pool_instances = 1
[mysqld_safe]
log-error=/home/data/3306/mysqld-err.log
“` 编辑/opt/mysql/3307.cnf
“`
[mysql]
prompt = “u@3307R:m:s [d]> ”
[client]
port =3307
socket = /data/mysql/data/mysql.sock
[免费主机域名mysqld]
datadir=/home/data/3307
socket=/home/data/3307/mysql.sock
skip-name-resolve
symbolic-links=0
log_bin = binlog
binlog_format= ROW
slow_query_log = 1
slow_query_log_file = slow.log
log-error = error.log
innodb_buffer_pool_size =512MB
innodb_buffer_pool_instances = 1
“` 编辑/opt/mysql/3308.cnf
“`
[mysql]
prompt = “u@3308R:m:s [d]> ”
[client]
port =3308
socket = /data/mysql/data/mysql.sock
[mysqld]
datadir=/home/data/3308
socket=/home/data/3308/mysql.sock
skip-name-resolve
symbolic-links=0
log_bin = binlog
binlog_format= ROW
slow_query_log = 1
slow_query_log_file = slow.log
log-error = error.log
innodb_buffer_pool_size =512MB
innodb_buffer_pool_instances = 1
“` 以上是“多实例安装mysql 5.7的示例分析”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注云技术行业资讯频道!
相关推荐: mysql update join如何优化update in查询效率
这篇文章主要为大家展示了“mysql update join如何优化update in查询效率”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“mysql update join如何优化update in查询效率”这篇…