MYSQL设置触发器权限问题的解决方法_Mysql_脚本之

时间:2019-11-28 21:04来源:江苏十一选五手机版数据库
先延续好数据库,然后展开左边 对象财富微型机,选用数据库  右键单击--- 选取导入数据层应用程序 本文实例汇报了MYSQL设置触发器权限的点子,针对权限错误的气象非常实用。具体

先延续好数据库,然后展开左边 对象财富微型机,选用数据库  右键单击 ---> 选取导入数据层应用程序

本文实例汇报了MYSQL设置触发器权限的点子,针对权限错误的气象非常实用。具体解析如下:

本文主要介绍mysql的设置和中坚接收、数据库导入导出和机关备份,然后介绍安全形式改过密码和mysql的全文本寻找效果,最终记录了私家使用mysql中相遇的主题素材集。

据书上说提醒向导一步步走就能够了

mysql导入数据提示未有SUPEHaval Privilege权限处理,如下所示:

江苏十一选五手机版 1

 

ERROR 1419 : You do not have the SUPER Privilege and Binary Logging is Enabled

千帆竞发设置:

sudo apt-get install mysql-common mysql-server

江苏十一选五手机版 2

导入function 、 trigger 到 MySQL database,报错:

简短利用

建库

CREATE DATABASE IF NOT EXISTS yourdbname DEFAULT CHARSET utf8 COLLATE utf8_general_ci;

建表

create table MyClass(id int(4) not null primary key auto_increment,name char(20) not null,sex int(4) not null default '0',degree double(16,2));

insert into MyClass values(1,'Tom',96.45),(2,'Joan',82.99), (2,'Wang', 96.59);

delete from MyClass where id=1;

update MyClass set name='Mary' where id=1;

江苏十一选五手机版,查

select * from MyClass;

呈现全体的view

select * from information_schema.TABLES where table_type='view' AND table_schema = '数据库名';

 

You do not have the SUPER privilege and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)”.

尤其操作

开创顾客:

create user xxx identified by ‘password’;

重命名:

rename user aaa to bbb;

除去顾客:

drop user aaa;

呈现权限:

show grants for aaa(用户);

授予权限:

grant select on xxx(数据库).* to aaa(用户);

予以有个别数据库的整个权力:

grant all on  xxx(数据库).* to aaa(用户);
grant all on  xxx(数据库).* to aaa(用户)@localhost;

收回授权:

revoke all on *.* from aaa(用户)@localhost;

改进权限

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%’   WITH GRANT OPTION;

上述操作完毕未来记得刷新权限:

flush privileges;

江苏十一选五手机版 3

原因:function / trigger 中有dangerous statements改良数据库,错误只在启用binary logging选项举办主从复制的服务器上冒出。

导入导出

导出数据和表构造:

mysqldump -uroot -p abc(数据库名) > abc.sql
敲回车后输入密码

只导出表构造

mysqldump -uroot -p -d abc > abc.sql

导入数据库
1、首先建空数据库

mysql> create database abc;

2、导入数据库

mysql -u root -p abc(数据库名) < abc.sql

 

减轻格局如下:

数据库自动备份

新建备份脚本xxx.sh,输入以下内容

#!/bin/bash

# 要备份的数据库名,多个数据库用空格分开
databases=("db1", "db2") 

# 备份文件要保存的目录,注意当前用户必须用户保存目录的读写权限
basepath='/root/backup/mysql/'

if [ ! -d "$basepath" ]; then
  mkdir -p "$basepath"
fi

# 循环databases数组
for db in ${databases[*]}
  do
    # 备份数据库生成SQL文件
    nice -n 19 /usr/bin/mysqldump -uroot -pcd32d5e86e --database $db > $basepath$db-$(date +%Y%m%d).sql

    # 将生成的SQL文件压缩
    nice -n 19 tar zPcf $basepath$db-$(date +%Y%m%d).sql.tar.gz -C $basepath $db-$(date +%Y%m%d).sql

    # 删除7天之前的备份数据
    find $basepath -mtime +7 -name "*.sql.tar.gz" -exec rm -rf {} ;
  done

  # 删除生成的SQL文件
  rm -rf $basepath/*.sql

动用crontab设置准时职分,在终端输入crontab -e,加入以下内容,此职责为每一天3点自动实践。

0 3 * * * bash xxx.sh(此处填写脚本绝对地址)

 

1)导入数据的客户不独有要求CREATE ROUTINE, ALTEWrangler ROUTINE, CREATE TLacrosseIGGECR-V, ALTEENVISION T揽胜极光IGGEGL450, CREATE FUNCTION 和 ALTE汉兰达 FUNCTION 权限,还亟需SUPETiggoprivileges 权限,使用顶尖客商导入数据。

敞开日志记录

[mysqld]
server-id = 1
log_bin = /var/log/mysql/mysql-bin.log
max_binlog_size = 1000M
binlog-format = row

江苏十一选五手机版 4

2)让抱有顾客全体实践雷同functions的权位,危急,不推荐,

安全情势操作

跻身安全方式修改密码

mysqld_safe --skip-grant-tables &

select user,host,password from user where user="root"

今非昔比版本的mysql改良客商密码情势不平等,必要查阅mysql->user中的密码字段,假如不是password的话就是authentication_string。

authentication_string的改换章程不太生龙活虎致:

use mysql;
update user set authentication_string=PASSWORD("") where User='root';
update user set plugin="mysql_native_password";
flush privileges;
quit;
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start

只要不是authentication_string,则可用以下方法。

update user set password=PASSWORD("your_password") where user="root" and host=“localhost"

 

 o by specifying it on the server start, like: –log-bin-trust-function-creators=1 o by setting it to 1 through the SET GLOBAL statement, like:mysql> SET GLOBAL log_bin_trust_function_creators = 1;

新操作

Mysql全文本寻觅

Mysql5.6后头扶持InnoDB,粤语的全文本找出,内置使用n-gram为分词微机,还帮助粤语~。

创建索引

create fulltext index ngram_idx on tag(Title) with parser ngram;
或
alter table tag add fulltext index ngram_idx(Title) with parser ngram;

获得帮忙的最小分词长度

SHOW VARIABLES LIKE 'ft_min_word_len';
//unix系统可在/etc/my.cnf中修改
[mysqld]
ft_min_word_len = 1

伊始选用

select Title,match(Title) against('清水') from tag ;

局地导入战败以至管理方案

3)若是无需复制,只怕是从库,关闭binlog,

莫不现身的标题集:

  • 描述
2017-05-04T01:21:32.004560Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2017-05-04T01:21:32.023009Z mysqld_safe A mysqld process already exists

消除格局:

$ sudo killall mysqld
  • 描述
2017-05-04T01:22:26.486677Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2017-05-04T01:22:26.488204Z mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists.

消灭方法:

sudo mkdir -p /var/run/mysqld
sudo chown -R mysql:mysql /var/run/mysqld
  • 描述
$ sudo /etc/init.d/mysql start
ies: No such file or directory
job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
[....] Starting mysql (via systemctl): mysql.servicejob-working-directory: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.

化解措施:

当前文件夹不是实际目录导致
cd到一个实际目录位置即可
  • 描述
sudo /etc/init.d/mysql start
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
[....] Starting mysql (via systemctl): mysql.servicejob-working-directory: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.

按照提示:See "systemctl status mysql.service" and "journalctl -xe" for details.
但是并么有什么卵用,直接看mysql的log:/var/log/mysql/error.log
2017-05-04T01:37:56.583745Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.

消除方法:

杀掉所有mysqld进程:killall mysqld 
再次sudo /etc/init.d/mysql start 成功
  • 描述
dpkg被锁定

消除措施

sudo rm /var/cache/apt/archives/lock
sudo rm /var/lib/dpkg/lock

非常1 : 在数据库master中拒却 create database 权限

# binary logging – not required for slaves, but recommended#log-bin=mysql-bin# binary logging format – mixed recommended#binlog_format=mixed

  管理方式:恐怕你眼下登入的客商名还未有该权限,能够一向动用Windows身份验证

愿意本文所述对我们的MySQL数据库设计具备助于。

 

特别2 : 无法用排他锁锁定该数据库,以实施该操作。 (.Net SqlClient Data Provider)

  处理办法:大概又其它进度或地点在利用该数据库,重启数据库服务解决

 

编辑:江苏十一选五手机版数据库 本文来源:MYSQL设置触发器权限问题的解决方法_Mysql_脚本之

关键词: