centos7 安装mysql57
来源:互联网 发布:数组怎么用 编辑:程序博客网 时间:2024/06/07 02:31
个人经验,直奔主题,centos7采用yum安装mysql-server 避免了各种人为的处理依赖。
1,下载官方Yum源:http://dev.mysql.com/downloads/repo/
# wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
直接将mysql*.rpm文件下载下来之后执行下列操作
sudo yum localinstall mysql57-community-release-el7-*.noarch.rpm
完成上面两步之后直接进入下一步
sudo yum install mysql-server
2,更新/etc/my.cnf或/etc/mysql/my.cnf
因为更新配置文件可能会依照特定需求修改mysql数据文件及日志文件等存储目录,为确保mysql用户对新目录拥有相应的权限,可在更新配置文件前将原mysql拥有目录复制至新目录:
[mysqld]datadir=/home/mysqlsocket=/var/lib/mysql/mysql.sockuser=mysqlskip-name-resolveskip-grant-tables # Disabling symbolic-links is recommended to prevent assorted security risks#symbolic-links=0transaction-isolation=READ-COMMITTED# Disabling symbolic-links is recommended to prevent assorted security risks;# to do so, uncomment this line:# symbolic-links=0key_buffer = 16Mkey_buffer_size = 32Mmax_allowed_packet = 16Mthread_stack = 256Kthread_cache_size = 64query_cache_limit = 8Mquery_cache_size = 64Mquery_cache_type = 1# Important: see Configuring the Databases and Setting max_connectionsmax_connections = 750# log-bin should be on a disk with enough free space#log-bin=/x/home/mysql/logs/binary/mysql_binary_log# For MySQL version 5.1.8 or later. Comment out binlog_format for older versions.#binlog_format = mixedread_buffer_size = 2Mread_rnd_buffer_size = 16Msort_buffer_size = 8Mjoin_buffer_size = 8M# InnoDB settingsinnodb_file_per_table = 1innodb_flush_log_at_trx_commit = 2innodb_log_buffer_size = 64Minnodb_buffer_pool_size = 4Ginnodb_thread_concurrency = 8innodb_flush_method = O_DIRECTinnodb_log_file_size = 512M[mysqld_safe]log-error=/var/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pid
2.3安装MySQL JDBC Connector
sudo yum install mysql-connector-java
2.4启动Mysql
sudo service mysqld start
2.5设置Mysql的root密码,初始密码为空(非必须)rootcentos
$ sudo /usr/bin/mysql_secure_installation
[…]
Enter current password for root (enter for none):
OK, successfully used password, moving on…
[…]
Set root password? [Y/n] y
New password:
Re-enter new password:
Remove anonymous users? [Y/n] Y
[…]
Disallow root login remotely? [Y/n] N
[…]
Remove test database and access to it [Y/n] Y
[…]
Reload privilege tables now? [Y/n] Y
All done!
2.6设置Mysql为开机自动启动
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
2.7为Cloudera Manager创建MySQL Databases(本人做集群用)
(1)用root登陆Mysql:$ mysql -u root –p
(2)脚本
create database amon DEFAULT CHARACTER SET utf8;
grant all on amon.* TO ‘amon’@’%’ IDENTIFIED BY ‘amon_password’;
create database smon DEFAULT CHARACTER SET utf8;
grant all on smon.* TO ‘smon’@’%’ IDENTIFIED BY ‘smon_password’;
create database rman DEFAULT CHARACTER SET utf8;
grant all on rman.* TO ‘rman ‘@’%’ IDENTIFIED BY ‘rman_password’;
create database hmon DEFAULT CHARACTER SET utf8;
grant all on hmon.* TO ‘hmon’@’%’ IDENTIFIED BY ‘hmon_password’;
create database hive DEFAULT CHARACTER SET utf8;
grant all on hive.* TO ‘hive’@’%’ IDENTIFIED BY ‘hive_password’;
create database nav DEFAULT CHARACTER SET utf8;
grant all on nav.* TO ‘nav’@’%’ IDENTIFIED BY ‘nav_password’;
(3)执行实例
Create a database for the Activity Monitor. The database name, user name, and password can be anything you want. For example:
mysql> create database amon DEFAULT CHARACTER SET utf8;
Query OK, 1 row affected (0.00 sec)
mysql>grant all on amon.* TO ‘amon’@’%’ IDENTIFIED BY ‘amon_password’;
Query OK, 0 rows affected (0.00 sec)
(3)Create a database for the Service Monitor. The database name, user name, and password can be anything you want. For example:
mysql> create database smon DEFAULT CHARACTER SET utf8;
Query OK, 1 row affected (0.00 sec)
mysql> grant all on smon.* TO ‘smon’@’%’ IDENTIFIED BY ‘smon_password’;
Query OK, 0 rows affected (0.00 sec)
(4)Create a database for the Report Manager. The database name, user name, and password can be anything you want. For example:
mysql> create database rman DEFAULT CHARACTER SET utf8;
Query OK, 1 row affected (0.00 sec)
mysql> grant all on rman.* TO ‘rman ‘@’%’ IDENTIFIED BY ‘rman_password’;
Query OK, 0 rows affected (0.00 sec)
(5)Create a database for the Host Monitor. The database name, user name, and password can be anything you want. For example:
mysql> create database hmon DEFAULT CHARACTER SET utf8;
Query OK, 1 row affected (0.00 sec)
mysql> grant all on hmon.* TO ‘hmon’@’%’ IDENTIFIED BY ‘hmon_password’;
Query OK, 0 rows affected (0.00 sec)
(6)Create a database for the Hive metastore. The database name, user name, and password can be anything you want. For example:
mysql> create database hive DEFAULT CHARACTER SET utf8;
Query OK, 1 row affected (0.00 sec)
mysql> grant all on hive.* TO ‘hive’@’%’ IDENTIFIED BY ‘hive_password’;
Query OK, 0 rows affected (0.00 sec)
(7)Create a database for Cloudera Navigator. The database name, user name, and password can be anything you want. For example:
mysql> create database nav DEFAULT CHARACTER SET utf8;
Query OK, 1 row affected (0.00 sec)
mysql>grant all on nav.* TO ‘nav’@’%’ IDENTIFIED BY ‘nav_password’;
Query OK, 0 rows affected (0.00 sec)
2.8为Mysql设置备份
使用mysqldump,命令格式如下:
mysqldump-h-u-p>/tmp/.sql
For example, to back up database scm_database on the local host as the root user, with the password mypasswd:
如果你顺利的执行到此处,恭喜你,很顺利,但是本人在实际中遇到了问题,问题描素就是:
1,Access denied for user ‘root’@’localhost’ (using password: NO)
处理方法:密码不对
[root ~]# grep 'temporary password' /var/log/mysqld.log2017-07-05T07:32:13.291107Z 1 [Note] A temporary password is generated for root@localhost: l(0P<cNuwMd1
执行之后找到密码,登录之后继续上诉的2.5步骤
2,[ERROR] InnoDB: Unable to lock ./ibdata1 error: 11
[Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data
or log files.
处理方法:有进程共用mysqlid
mysqld stopservice mysqld stopps -ef|grep mysql*kill -9 对应的进程id
以上基本上可以处理这个问题了之后再重启mysql (service mysqld start),此时进入上诉2.4步骤
3,service mysql start failed
改问题与上诉2问题类似
# lsof -i:3306
查看mysql有没有进行,之后按照2的处理方式进行处理
4, Failed! Error: Your password does not satisfy the current policy requirements
处理方法: 你的密码级别很高,重置的密码级别不高,重设
5,改密码级别
进入mysql之后
set global validate_password_policy=0;set global validate_password_length=0; SET PASSWORD FOR 'root'@'localhost' = PASSWORD('root');
- centos7 安装mysql57
- centos7安装mysql57
- centos7 安装mysql57
- CentOS7使用yum安装MySql57默认密码问题
- MySQL57安装图解
- 解决MySQL安装版出现the the service mysql57 failed问题的方法。
- 跟着SY速学Ubuntu系列二:Ubuntu16 编译安装 Apache24&&PHP7&&Mysql57
- centos7安装
- CentOS7安装
- CentOS7安装
- 安装centOS7
- Centos7安装
- 安装Centos7
- centos7 安装
- centos7安装
- centos7安装
- 安装centos7
- CentOS7安装
- Android硬件加速问题
- 浅谈C++类中的默认成员函数
- PHP魔术方法 __sleep和__wakeup()
- leetcode: 628. Maximum Product of Three Numbers
- Hamming distance- leetcode
- centos7 安装mysql57
- JPA入门例子(采用JPA的hibernate实现版本)
- Spring4.X 与 Hibrenate5.X整合
- CSS之Multi-columns的跨列
- 如何优化eclipse?eclipse启动很卡,很慢?性能不好?
- 递归算法及应用
- Unity5.x Time用法详解
- linux虚拟终端之screen命令
- 跨域之Server Proxy