Mysql安装:GPG报错处理
Mysql安装报错:GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
下载 mysql 源安装包。 wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm 安装 mysql 源。 yum localinstall mysql57-community-release-el7-8.noarch.rpm 检查 mysql 源是否安装成功 yum repolist enabled | grep "mysql.*-community.*" 输入以下指令,安装 MySQL。 yum install mysql-community-server 启动 MySQL 服务。 systemctl start mysqld 查看 MySQL 启动状态。 systemctl status mysqld 输入以下指令,配置 Mysql 开机启动。 systemctl enable mysqld systemctl daemon-reload 查看root 并记录默认密码,用于后续登陆 grep 'temporary password' /var/log/mysqld.log 登录 MySQL。 mysql -u root -p 修改 MySQL root 的密码 ALTER USER 'root'@'localhost' IDENTIFIED BY 'Password';
mysql>界面输入以下命令新建同步账户: create user 'copy'@'172.16.%' identified by 'huawei@123'; mysql>界面输入以下命令为同步账户授予复制权限: grant replication slave on *.* to 'copy'@'172.16.%' identified by 'Password';
设置允许root所有访问:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Password' WITH GRANT OPTION;
开启远程控制 : update user set host='%' where user='用户名'; 取消远程控制: update user set host='localhost' where user='用户名'; 删除用户 : delete from user where user="用户名" and host='host权限(localhost/%)'; 设置显示某一个数据库的权限: grant all on 数据库名.* to 用户名; 若没有马上生效,则输入 : flush privileges;
查看MYSQL数据库中所有用户权限
SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;
本地编译安装
卸载默认源mariadb yum -y remove mariadb* 下载安装包 wget https://hciecloud.obs.cn-north-4.myhuaweicloud.com/MySQL-5.6.45-1.el6.x86_64.rpm-bundle.tar mkdir mysql_install tar -xvf MySQL-5.6.45-1.el6.x86_64.rpm-bundle.tar -C mysql_install cd mysql_install yum install -y MySQL-*.rpm yum install -y MySQL-shared-compat-5.6.45-1.el6.x86_64.rpm yum install -y MySQL-server-5.6.45-1.el6.x86_64.rpm yum install -y MySQL-client-5.6.45-1.el6.x86_64.rpm yum install -y MySQL-devel-5.6.45-1.el6.x86_64.rpm yum install -y MySQL-shared-5.6.45-1.el6.x86_64.rpm 启动mysql systemctl start mysql 查询root默认密码 cat /root/.mysql_secret
my.cnf文件
[mysqld] join_buffer_size = 128M sort_buffer_size = 2M read_rnd_buffer_size = 2M datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock # Disabling symbolic-links is recommended to prevent assorted security risks lower_case_table_names = 1 innodb_strict_mode = 1 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES symbolic-links=0 character_set_server = utf8 log-bin = mysql-bin binlog_format=row #####主库 从库id不能一样###### server-id = 2 #####主库 从库id不能一样###### expire_logs_days = 10 slave_skip_errors = 1062 log_slave_updates = 1 [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid