MySQL平常的配置总结

MySQL 忘记密码mysql

1:停掉数据库sql

2: 找到my.cnf 增长 skip-grant-tables #是安全登陆 能够不使用密码 进行登陆,数据库

3:启动数据库安全

4:mysql -uroot服务器

5:use mysqlthis

6:update user set password = password('new_password') where user='root'spa

6.1 (5.7+) update user set authentication_string = password('new_password') where user='root';日志

7 退出code

8 停掉数据库server

9 my.cnf 注掉 skip-grant-tables

10 启动数据库

11  if ERROR 1820 (HY000): You must SET PASSWORD before executing this statement 

12 set password = password('newPassword')

MySQL 的主从数据库

1:调整主数据库的访问权限,从数据库能够进行访问(更改 mysql 数据库 user表 中的host列%表示任何IP)

2:找到 my.cnf 添加

server-id=1   //给数据库服务的惟一标识,通常为你们设置服务器Ip的末尾号
log-bin=master-bin3 log-bin-index=master-bin.index
log-bin-index=master-bin.index

 

3:查看日志 show master status

+-------------------+----------+--------------+------------------+

| File                        | Position | Binlog_Do_DB | Binlog_Ignore_DB |

+-------------------+----------+--------------+------------------+

| master-bin.000003 |      106 |              |                  |

+-------------------+----------+--------------+------------------+

/**

    记住 上面的 参数, 对后面来讲很急很关键

*/

4: 这样主数据库的配置就行了,如今能够重启了

-------------------------------------------------------------------------------------------

配置从数据库(配多少个都同样)

1: 找到my.cnf

[mysqld]
server-id=2
relay-log-index=slave-relay-bin.index
relay-log=slave-relay-bin

 

2:进到从数据库中:

输入:

change master to master_host='192.168.0.104', //Master 服务器Ip
master_port=3306,
master_user='repl',
master_password='mysql', 
master_log_file='file',//show master status --> file
master_log_pos=position;//show master status --> position

3:重启从数据库

总结 : 

    上面的操做全是看的别人的, 我配置的时候,重启了不少次, 可是认为没有必要, 因此在配置完后才重启,

    但愿这能帮到你 ^_^

相关文章
相关标签/搜索