码迷,mamicode.com
首页 > 数据库 > 详细

mysql 安装及卸载 主从配置

时间:2016-09-11 17:23:07      阅读:254      评论:0      收藏:0      [点我收藏+]

标签:

1.查询rpm -qa | grep mysql* 组件
出现类似安装包
mysql-server-5.1.71-1.el6.x86_64

mysql-libs-5.1.71-1.el6.x86_64

mysql-connector-odbc-5.1.5r1144-7.el6.x86_64

mysql-5.1.71-1.el6.x86_64

mysql-devel-5.1.71-1.el6.x86_64

2.卸载系统已安装的mysql,移除lib包

yum remove mysql-libs

3.检测是否卸载完全

rpm -qa | grep mysql*
没有软件判定已卸载完全

3.用户

groupadd mysql
useradd -d /mnt/mysql -g mysql mysql

passwd mysql

--输入两次密码

4.先复制配置文件,再安装mysql

 

4.安装mysql,/usr/soft

rpm -ivh MySQL-server-5.6.32-1.linux_glibc2.5.x86_64.rpm

rpm -ivh MySQL-client-5.6.32-1.linux_glibc2.5.x86_64.rpm

4. my.cnf文件

 

# For advice on how to change settings please see

# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html

 

 

[client]

#password=123456

port=3306

socket=/mnt/mysql/mysql.sock

default-character-set=utf8

 

[mysqld]

character-set-server=utf8

lower_case_table_names=1

# Remove leading # to turn on a very important data integrity option: logging

# changes to the binary log between backups.

log_bin=mysql-bin

 

 

#主机配置

#主机运行命令GRANT REPLICATION SLAVE ON *.* TO ‘sqlsync‘@‘%‘ IDENTIFIED BY ‘123456‘;

#read-only=0  #主机,读写都可以

#binlog-do-db =test   #需要备份数据,多个写多行

#binlog-ignore-db =mysql #不需要备份的数据库,多个写多行

 

 

# These are commonly set, remove the # and set as required.

#basedir = /mnt/mysql

datadir = /mnt/mysql

port = 3306

server_id = 1    

#服务器唯一ID,默认是1,一般取IP最后一段

socket = /mnt/mysql/mysql.sock

max_connections=1000

# Remove leading # to set options mainly useful for reporting servers.

# The server defaults are faster for transactions and fast SELECTs.

# Adjust sizes as needed, experiment to find the optimal values.

# join_buffer_size = 128M

# sort_buffer_size = 2M

# read_rnd_buffer_size = 2M

 

 

#从机配置,主机不需要打开

#master-host=192.168.229.129

#master-user=mysnyc

#master-pass=123456

#master-port=3306

#master-connect-retry=60 #如果从服务器发现主服务器断掉,重新连接的时间差(秒)

#replicate-do-db =test #只复制某个库

#replicate-ignore-db=mysql #不复制某个库

log-slave-updates=ON

sync_binlog=1

auto_increment_offset=2 

#便于区分,server id 为1的 设为1   为2的设为2

auto_increment_increment=2

slave-skip-errors=all

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

 

[mysql]

default-character-set=utf8

 

 

 

 

4.修改root密码

 

su – mysql

可以不启动此语句,进入/root/.mysql_secret 看到root密码登陆
--mysqld_safe --user=root --skip-grant-tables --skip-networking &  --省略

 

service mysql start


--mysql -u root mysql  --省略

使用此语句

mysql –u root –p

输入默认密码

修改默认密码set password = password("123456");

mysql> use mysql;
mysql> UPDATE user SET Password=PASSWORD(‘123456‘) where USER=‘root‘;
mysql> FLUSH PRIVILEGES;
mysql> quit

service mysql restart
mysql -uroot -p

Enter password: <输入新设的密码newpassword>

quit

----------安装并设置成功

 

 

 

#如果提示ERROR 1820 (HY000): You must SET PASSWORD before executing this statement

#需要重新设置密码

set password = password("123456");

 

 

 

 

卸载mysql

yum remove mysql-libs

查找mysql安装包

rpm –qa|grep –i mysql

停止mysql服务

service mysql stop

rpm -e MySQL-client-5.6.32-1.linux_glibc2.5.x86_64

rpm -e MySQL-server-5.6.32-1.linux_glibc2.5.x86_64

删除mysql生成的部分文件

find / -name mysql

 rm –rf ……

 

 

 

主从配置:

 

 

配置主mysql

GRANT REPLICATION SLAVE ON *.* TO ‘mysync‘@‘%‘ IDENTIFIED BY ‘123456‘;

show master status;

 

 

配置从mysql

stop slave;//停止

change master to master_host=‘10.46.181.107‘,master_user=‘mysync‘,master_password=‘123456‘, MASTER_PORT=3306, MASTER_CONNECT_RETRY=10,master_log_file=‘mysql-bin.000004‘,master_log_pos=325;

start slave;

show slave status\G//查看状态

(主主 正好相反配置)

附:

创建用户并附所有权限

GRANT all privileges ON *.* TO ‘bwcloud‘@‘%‘ IDENTIFIED BY ‘123456‘;

FLUSH PRIVILEGES;

 

 

mysql 安装及卸载 主从配置

标签:

原文地址:http://www.cnblogs.com/clicli/p/5862014.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!