linux mysql5.5 一主多从配置

安装前必须删除原来的安装

需要检查 以下文件是否存在 ,如果存储则要删除之

/etc/my.cnf

/etc/init.d/mysqld

mysql 依赖的库

shell> yum search libaio # search for info

shell> yum install libaio # install library

创建mysql 与用户组,-s /bin/false 表示该用户不能登录

shell> groupadd mysql

shell> useradd -r -g mysql -s /bin/false mysql

解压安装包至指定目录

shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz

shell> ln -s full-path-to-mysql-VERSION-OS mysql

shell> cd mysql

mysql 用户添加权限

shell> chown -R mysql ./

shell> chgrp -R mysql ./

#创建data目录并添加权限

shell> mkdir -p /data/mysql

shell> chown -R mysql:mysql /data/mysql

拷贝配置文件

shell> cp ${basedir}/support-files/my-medium.cnf /etc/my.cnf

#修改配置

[mysqld]

basedir=/home/cbt/svr/mysql

datadir=/data/mysql

character-set-server=utf8

shell> cp support-files/mysql.server /etc/init.d/mysql

#添加环境变量

shell> vi /etc/profile

PATH=/home/cbt/svr/mysql/bin:$PATH

export PATH

#让刚才的修改生效

shell> source /etc/profile

启动及其它配置 #启动数据库

service mysql start

#开机启动

chkconfig mysqld on

#初始化mysql的一些设置

mysql_secure_installation

#回车

Enter current password for root (enter for none):

#y,设置mysqlroot密码

Set root password?[Y/n] y

#以下都yes

Remove anonymous users?[Y/n] y

Disallow root login remotely?[Y/n] y

Remove test database and access to it?[Y/n] y

Reload privilege tables now?[Y/n] y

ThanksforusingMySQL!

允许远程登陆

  1. mysql> use mysql;
  2. mysql> select host,user,password from user;
  3. mysql> update user set password=password('123456') where user='root';
  4. mysql> update user set host='%' where user='root' and host='localhost';
  5. mysql> flush privileges;

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值