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

#下載Mysql5.6
https://dev.mysql.com/downloads/file/?id=487423mysql

#安裝依賴包
yum install -y gcc gcc-c++ make tar openssl openssl-devel cmake ncureses ncurses-develc++

#新建mysql用戶
useradd -s /sbin/nologin mysqlsql

#解壓並編譯數據庫

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

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

#更新配置ide

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/

#安裝code

yum install -y perl-Module-Install

#數據庫初始化:server

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

#設置systemctl管理ip

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
相關文章
相關標籤/搜索