赞
踩
yum install -y vim
rpm -ivh perl-*rpm -ivh net-tools-2.0-0.22.20131004git.el7.x86_64.rpmrpm -ivh mysql-community-common-5.6.42-2.el7.x86_64.rpmrpm -ivh mysql-community-libs-5.6.42-2.el7.x86_64.rpmrpm -ivh mysql-community-client-5.6.42-2.el7.x86_64.rpmrpm -ivh mysql-community-server-5.6.42-2.el7.x86_64.rpm
# 1.添加官方的yum源创建并编辑mysql-community.repo文件vi /etc/yum.repos.d/mysql-community.repo# 2.粘贴以下内容到源文件中[mysql57-community]name=MySQL 5.7 Community Serverbaseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/enabled=1gpgcheck=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql#注意:如果需要安装mysql5.7只需要将baseurl修改即可# 3.安装mysqlsudo yum install -y mysql-community-server
# 1.启动mysql数据库[root@localhost mysql]# systemctl start mysqld# 2.查看mysql版本号[root@bogon usr]# mysql -V# 3.修改mysql数据库密码mysqladmin -u root -p password 回车 输入原始密码 在输入新的密码注意:5.7之前版本安装完成之后没有密码,mysql5.7之后的版本的初始密码是随机生成的,放在了 /var/log/mysqld.log使用命令 cat/var/log/mysqld.log 读出来即可 ,mysql5.6之后没有初始密码,可以使用:mysql -u root 命令直接登录,不用输入密码mysql5.6版本修改密码,使用命令: mysqladmin -u root -p password 'Root!123' ,因为mysql5.6没有初始密码-p后面不用输入密码,在password输入新密码,Root!123是新密码# 4.登录mysql[root@localhost mysql]# mysql -u root -p
1.修改/profile文件vi /etc/profile2.在文件的末尾,添加如下代码export MYSQL_HOME=mysql安装目录(/usr/local/mysql-5.7.36)export PATH=$PATH:$MYSQL_HOME/bin3.刷新文件source /etc/profile4.测试,切换到根目录然后登陆mysql,没有提示无法识别mysql说明配置成功cd /mysql -uroot -p
mysql -u root -p
set password for username @localhost = password(newpwd);
vi /etc/my.cnf
[mysqld]datadir=/var/lib/mysqlskip-grant-tables
systemctl restart mysqld
mysql -u root
update mysql.user set authentication_string=PASSWORD('Root!123') where User='root';
flush privileges;
set password for root@localhost = password('Root!123');
flush privileges;
rpm -qa|grep -i mysql
systemctl stop mysqldrpm -ev MySQL-client-5.5.25a-1.rhel5rpm -ev MySQL-server-5.5.25a-1.rhel5
rpm -ev MySQL-client-5.5.25a-1.rhel5 --nodeps
find / -name mysql
/var/lib/mysql/var/lib/mysql/mysql/usr/lib64/mysql
rm -rf /var/lib/mysqlrm -rf /var/lib/mysqlrm -rf /usr/lib64/mysql
rm -rf /etc/my.cnf
rpm -qa|grep -i mysql
192.168.202.201 master 主节点192.168.202.202 slave 从节点
[root@localhost mysql]# vim /etc/my.cnf
server-id=1log-bin=mysql-binlog-slave-updatesslave-skip-errors=all
server-id=2log-bin=mysql-binlog-slave-updatesslave-skip-errors=all
systemctl restart mysqld
SHOW VARIABLES like 'server_id';
show master status;
change master tomaster_host='192.168.80.129',master_user='root',master_password='root',master_log_file='mysql-bin.000001',master_log_pos=120;
start slave;
stop slave;
show slave status\G;
************************** 1. row ***************************Slave_IO_State: Waiting for master to send eventMaster_Host: 10.15.0.9Master_User: rootMaster_Port: 3306Connect_Retry: 60Master_Log_File: mysql-bin.000001Read_Master_Log_Pos: 120Relay_Log_File: mysqld-relay-bin.000002Relay_Log_Pos: 283Relay_Master_Log_File: mysql-bin.000001Slave_IO_Running: YesSlave_SQL_Running: Yes
stop slave;
http://dl.mycat.io/1.6-RELEASE/Mycat-server-1.6-RELEASE-20161028204710-linux.tar.gz
tar -zxvf Mycat-server-1.6-RELEASE-20161028204710-linux.tar.gz
[root@localhost mycat]# ls总用量 12drwxr-xr-x. 2 root root 190 10月 14 22:58 bindrwxrwxrwx. 2 root root 6 3月 1 2016 catletdrwxrwxrwx. 4 root root 4096 10月 14 22:58 confdrwxr-xr-x. 2 root root 4096 10月 14 22:58 libdrwxrwxrwx. 2 root root 6 10月 28 2016 logs-rwxrwxrwx. 1 root root 217 10月 28 2016 version.txt
mv mycat/ /usr/
<!-- 定义MyCat的逻辑库 dataNode代表映射真实数据节点--><schema name="test_schema" checkSQLschema="false" sqlMaxLimit="100" dataNode="testNode"></schema><!-- 定义MyCat的数据节点 name:名字必须和dataNode值一致 dataHost:映射真实主机 database:映射真实的库--><dataNode name="testNode" dataHost="dtHost" database="test" /><!-- 定义数据主机 name:名字必须和dataHost保持一致 --><dataHost name="dtHost" maxCon="1000" minCon="10" balance="1" writeType="0" dbType="mysql" dbDriver="native" switchType="-1" slaveThreshold="100"><!-- 心跳检测 --><heartbeat>select user()</heartbeat><!--写节点--><writeHost host="hostM1" url="192.168.28.128:3306" user="root" password="root"><!--从节点--><readHost host="hostS1" url="192.168.28.129:3306" user="root" password="root" /></writeHost></dataHost>
<system><!-- 这里配置的都是一些系统属性,可以自己查看mycat文档--><property name="defaultSqlParser">druidparser</property><!-- 编码,mysql版本如果是5.x必须是utf8--><property name="charset">utf8</property></system><!-- 配置用户信息 name:代表登陆mycat的用户名 password:代表登陆密码--><user name="root"><property name="password">root</property><!-- 用来指定可以操作的逻辑库--><property name="schemas">aa</property></user>
./mycat console
tail -f ../logs/mycat.log
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。