[[email protected] ]# tar -zxvf mysql-5.5.49.tar.gz
[[email protected] ]# cd mysql-5.5.49
[[email protected] mysql-5.5.49]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/data/mysql -DWITH_EXTRA_CHARSETS=all -DWITH_READLINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_TCP_PORT=3306 -DDEFAULT_COLLATION=utf8_general_ci
[[email protected] mysql-5.5.49]# make -j 4 && make install
[[email protected] mysql-5.5.49]# chown -R mysql.mysql /usr/local/mysql
[[email protected] mysql-5.5.49]# cd /usr/local/mysql/support-files/
6.拷贝mysql配置文件
[[email protected] support-files]# cp my-medium.cnf /data/mysql/my.cnf
[[email protected] support-files]# cp mysql.server /etc/init.d/mysqld
[[email protected] support-files]# chmod +x /etc/init.d/mysqld
7.初始化mysql
[[email protected] support-files]# cd /usr/local/mysql/scripts
[[email protected] scripts]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/data/mysql/
8.修改mysql的数据目录
[[email protected] ]# cd / && more /etc/my.cnf
[mysqld]
datadir=/data/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[[email protected] ]# mkdir -pv /var/lib/mysql/ && ln -s /tmp/mysql.sock /var/lib/mysql/
9.启动mysql
[[email protected] ]# ln -s /usr/local/mysql/bin/mysql /usr/bin/
[[email protected] ]# ln -s /usr/local/mysql/bin/mysqladmin /usr/bin/
[[email protected] ]# service mysqld start
[[email protected] ]# mysqladmin -uroot password "123456"
[[email protected] mysql]# more /etc/zabbix/.my.cnf
#zabbix_agent
[mysql]
host=localhost
user=root
password=123456
#socket=/tmp/mysql.sock
[mysqladmin]
host=localhost
user=root
password=123456
[[email protected] ]# mysql -u root -p123456
mysql> create database zabbix default charset utf8;
mysql> grant all privileges on zabbix.* to [email protected]‘localhost‘ identified by ‘zabbix‘;
mysql> grant all privileges on zabbix.* to [email protected]‘%‘ identified by ‘zabbix‘;
mysql> flush privileges;
mysql> show databases;
mysql> quit
vim /etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf
更换这三处路径写入 .my.cnf所在的绝对路径
重启zabbix—agentd 服务
当时我犯下一个错误就是在.my.cnf下的错 当时因为是源码包 mysql.sock在/var/lib/mysql/mysql.socl
而我写的是/tmp/mysql.sock 这个虽然可以做软连接 但是会报错的具体可以参考我的错误总结
然后再用默认模板就可以了 具体的操作就不在多写了 详情 不懂的可以加我qq 2413493695