偶尔一次安mysq老是东查西查的,现在就备份一下安装的过程

安装

1
2
3
4
apt install mysql-server
apt install mysql-client
apt install libmysqld-dev
apt install redis-server

中间会让我们配置mysql的密码

远程访问

1
mysql -u root -p
1
2
3
use mysql;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'your_root_password' WITH GRANT OPTION;
FLUSH PRIVILEGES;

修改配置文件

将 /etc/mysql/mysql.conf.d/mysqld.cnf 改成

1
# bind-address          = 127.0.0.1

重启mysql

1
/etc/init.d/mysql restart

同步相关

1
rsync -rav -r root@116.196.103.192:~/iot/ ./

备份数据库

1
mysqldump -uroot -p iot > dump.sql

备份redis数据库

1
rsync -avr -r root@116.196.103.192:var/lib/redis/dump.rdb /var/lib/redis/