首页 > 数据库技术 > 详细

[Zabbix+Grafana]系列之三:Mysql安装

时间:2019-08-09 23:50:51      阅读:155      评论:0      收藏:0      [点我收藏+]
#下载Mysql5.6
https://dev.mysql.com/downloads/file/?id=487423

#安装依赖包
yum install -y gcc gcc-c++ make tar openssl openssl-devel cmake ncureses ncurses-devel

#新建mysql用户
useradd -s /sbin/nologin mysql

#解压并编译

tar -zxvf 
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH-EXTRA_CHARSETS:STRING=all -DWITH_DEBUG=0 -DWITH_SSL=yes -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1
make && make install

#配置环境变量

vim /etc/profile
export PATH=$PATH:/usr/local/mysql/bin

#更新配置

vim /etc/my.cnf
[mysqld]
bind-address=0.0.0.0
port=3306
datadir=/data/mysql
user=mysql
skip-name-resolve
long_query_time=2
slow_query_log_file=/data/mysql/mysql-slow.log
expire_logs_days=2
innodb-file-per-table=1
innodb_flush_log_at_trx_commit=2
log_warnings=1
max_allowed_packet=512M
connect_timeout=60
net_read_timeout=120
[mysql]
default-character-set=utf8
[mysqld]
default-storage-engine=INNODB
character_set_server=utf8
[mysqld_safe]
log-error=/data/mysql/mysqld.log
pid-file=/data/mysql/mysqld.pid

#创建目录并修改属主

mkdir -pv /data/mysql
chown -R mysql:mysql /usr/local/mysql/ /data/mysql/

#安装

yum install -y perl-Module-Install

#数据库初始化:

/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --user=mysql --datadir=/data/mysql/

#设置systemctl管理

vim /usr/lib/systemd/system/mysqld.service

#修改mysql root密码

 mysqladmin -uroot -h 127.0.0.1 password ‘123456‘

#开启用户授权

 GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘192.168.0.%‘ IDENTIFIED BY ‘123456‘ WITH GRANT OPTION;

#登陆测试

mysql -h 192.168.0.1 -uroot -p123456 -A

[Zabbix+Grafana]系列之三:Mysql安装

原文:https://blog.51cto.com/ahaqwz/2428199

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!