mysql数据库备份一句话执行命令
mysqldump --all-databases -h127.0.0.1 -uroot -p123456 > allbackupfile.sql
提示如下提示
[root@yfvyy5b2on3knb8q opt]# mysqldump --all-databases -h127.0.0.1 > allbackupfile.sql
mysqldump: Couldn't execute 'SELECT COLUMN_NAME, JSON_EXTRACT(HISTOGRAM, '$."number-of-buckets-specified"') FROM information_schema.COLUMN_STATISTICS WHERE SCHEMA_NAME = 'mysql' AND TABLE_NAME = 'columns_priv';': Unknown table 'COLUMN_STATISTICS' in information_schema (1109)
直接上干货解决办法(大概就是直接熟人密码不安全)
vim /etc/my.cnf
添加账户和密码
重启MySQL服务
[root@yfvyy5b2on3knb8q bin]# service mysql stop Shutting down MySQL.. SUCCESS! [root@yfvyy5b2on3knb8q bin]# service mysql start
继续执行mysqldump命令,提示仍然报错
mysqldump: Couldn't execute 'SELECT COLUMN_NAME, JSON_EXTRACT(HISTOGRAM, '$."number-of-buckets-specified"') FROM information_schema.COLUMN_STATISTICS WHERE SCHEMA_NAME = 'mysql' AND TABLE_NAME = 'columns_priv';': Unknown table 'COLUMN_STATISTICS' in information_schema (1109)
--column-statistics=0 (版本原因需添加此段内容)
mysqldump --column-statistics=0 --all-databases -h 127.0.0.1 > /opt/allbackupfile1.sql
导入操作
llbackupfile1.sql allbackupfile.sql all_databases_backup.sql backup.sh mysql-8.0.36-linux-glibc2.28-x86_64.tar.xz osmt
[root@yfvyy5b2on3knb8q opt]# mysql -h 127.0.0.1 -P 3306 -u root -p test< allbackupfile1.sql