关键词:mysql5.6;安装包安装;
MySQL
(1)查找并卸载系统已经安装的mysql
# rpm -qa | grep mysql
# rpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64
(2)安装libaio
链接:https://pan.baidu.com/s/1yP9dO1WxmZpurXJ2d4_tfA 密码:qlyb
# rpm -ivh libaio-0.3.109-13.el7.x86_64.rpm
(3)安装MySQL
链接:https://pan.baidu.com/s/14hyu8ltY0zOWTu0GhHa8OA 密码:pz06
# tar -xbf MySQL-5.6.26-1.linux_glibc2.5.x86_64.rpm-bundle.tar
# rpm -ivh MySQL*.rpm
(4)配置数据库
# cp /usr/share/mysql/my-default.cnf /etc/my.cnf
# vim /etc/my.conf
备注:
cp拷贝dir1目录的my-default.cnf,到dir2目录下,命名为my.cnf
数据库配置文件【my.conf】
default-storage-engine = innodb
innodb_file_per_table
collation-server = utf8_general_ci
init-connect = 'SET NAMES utf8'
character-set-server = utf8
max_allowed_packet = 100M
(5)初始化并启动数据库
# cd /usr/bin/mysql_install_db
# service mysql start
# chkconfig mysql on
(6)修改数据库临时密码
# cat /root/.mysql_secret # cat命令cat(concatenate)命令用于显示文件的内容
# mysqladmin -uroot -pDZxvfVLLeJQGR7Mq password 123456
%%YY:此处提示错误
mysqladmin: connect to server at 'localhost' failed
error:‘your password has expired, to log in you must change it using a client that that support expired passwords.’
停止mysql服务
# service mysql stop
mysql安全模式启动,跳过权限控制表
# cd /usr
# mysqld_safe --user=mysql --skip-grant-tables
备注:
--skip-grant-tables:不启动grant-tables(授权表),跳过权限控制。
--skip-networking :跳过TCP/IP协议,只在本机访问(这个选项不是必须的。可以不用)
登录mysql服务,使用mysql数据库,查询myqsl用户信息
# mysql
mysql> use mysql;
mysql> select host,user,authentication_string,password_expired from user;
备注:
authentication_string字段就是password用户密码;
password_expired字段,对应密码是否过期,Y,过期,N,永不过期。
重置用户名为root的密码为123456,输入SQL命令:
mysql>update user set authentication_string=PASSWORD('123456') where user='root' ;
设置密码永不过期
mysql>alter user 'root'@'localhost' password expire never;
mysql>update user set password_expired='N' where user='root' \;
#数据库设置更新,生效,退出
mysql>flush privileges;
mysql>quit
bye
重新登录mysql
#mysql -uroot -p123456
重启数据库服务
# service mysql restart
(7)创建zabbix数据库及用户并赋予相关权限
mysql -u root -p123456
CREATE DATABASE zabbix CHARACTER SET UTF8 COLLATE UTF8_BIN;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456';
GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost IDENTIFIED BY '123456';
FLUSH PRIVILEGES;