password
修改/etc/my.cnf配置文件
增加skip-grant-tables
重启 mysql
/etc/init.d/mysql restart or /etc/init.d/mysqld restart
使用 #mysql
update user set authentication_string=password('填入新密码”') where user='root'; flush privileges;
创建数据库,并设置默认编码
mysql> CREATE DATABASEtest_dbDEFAULT CHARACTER SET utf8;
导入 sql 脚本
mysql> use test_db; mysql> source /home/gaoshuai/test.sql
mysqldump 备份不建议在脚本中直接使用密码,可以通过以下方式解决
##1.在你的用户根目录下面创建一个.my.cnf 文件添加以下内容(隐藏文件)
[mysqldump] user="username" password ="password"
##2.添加完后修改他的权限防止其他用户使用
chmod 600 .my.cnf
##3.下面就可以不输入密码直接使用了,修改备份脚本
/usr/bin/mysqldump -uroot db >db.sql
注意 mysqldump 默认不会 dump 存储过程,如果需要 dump 存储过程,请使用-R 参数
使用下面语句查看存储过程
shell SELECT \* FROM information_schema.ROUTINESWHERE ROUTINE_SCHEMA="gaoshuai";
编辑 (opens new window)
上次更新: 2023/02/24, 10:34:03