CentOS ARM Mysql5.6.44
环境部署:
--Mysql版本:mysql-5.6.44-aarch64.tar.gz
--关闭防火墙:
systemctl stop firewalld
systemctl disable firewalld
--关闭selinux:
vim /etc/sysconfig/selinux
改成disabled (永久关闭)
setenforce 0 (临时关闭)
mysql5.6.44包下载地址为:
https://obs-mirror-ftp4.obs.cn-north-4.myhuaweicloud.com/database/mysql-5.6.44-aarch64.tar.gz
链接: https://pan.baidu.com/s/1RGmnLXBKPPMgXrMI3Hsyug 密码: evw2
卸载MariaDB
rpm -qa | grep -i mariadb rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
卸载已有Mysql
卸载旧版本mysql
rpm -qa | grep -i mysql
如果有,就使用上面卸载mariadb的命令进行卸载、删除服务
systemctl list-unit-files --type=service | grep -i mysql
如果查找到mysql服务,使用下面的命令进行删除 chkconfig --del mysql
删除mysql分散的文件夹
[root@localhost ~]# whereis mysql mysql: /usr/lib64/mysql rm -rf /usr/lib64/mysql
依赖安装
yum install perl
yum -y install autoconf
yum install gcc gcc-c++ libaio*
添加mysql用户组和mysql用户
groupadd -r mysql && useradd -r -g mysql -s /sbin/nologin -M mysql
解压MySQL包
tar -xzvf mysql-5.6.44-aarch64.tar.gz -C /usr/local
创建Myslq配置路径&&设置权限
mkdir -p /usr/local/mysql/logs
mkdir -p /data/mysql
--
chown -R mysql:mysql /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql-5.6.44-arrch64
chown -R mysql:mysql /data/mysql
添加软连接
ln -s /usr/local/mysql-5.6.55-arrch64 /usr/local/mysql
初始化Mysql
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql
配置Mysql
---执行完初始化Mysql后/usr/local/mysql目录下会生成一个my.cnf,如果没有或者是第二次初始化,则会生成my-new.cnf。只保留新的my.cnf,将第一次初始化my.cnf删掉,my-new.cnf更名为my.cnf
--追加以下配置
#skip-grant-tables
basedir=/usr/local/mysql
datadir=/data/mysql
(此处配置的路径与初始化路径配置的路径必须一致)
添加软连接
ln -sf /usr/local/mysql/my.cnf /etc/my.cnf
设置开机自启
cp -rf /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
systemctl enable mysqld
添加环境变量
vim /etc/profile
---
export MYSQL_HOME=/usr/local/mysql
export PATH=$PATH:$MYSQL_HOME/bin
source /etc/profile
启动mysql
systemctl start mysqld
systemctl status mysqld
绕过密码登录(安全登录)
##centos7
[root@localhost mysoft]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking & [1] 1522 [root@localhost mysoft]# Logging to '/var/lib/mysql/localhost.localdomain.err'. 19052817:25:33 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
##centos6
[root@localhost mysoft]# sudo mysqld_safe --skip-grant-tables &
登录mysql
mysql (默认密码为空)
切换数据库
use mysql
查询用户
select Host,User,Password from user;
修改密码为tgram123
UPDATE user SET password=password("tgram123") WHERE user='root';
mysql> flush privileges;
exit
注意
注意密码字段名5.7版本的是authentication_string,之前的为password。
重启mysql服务
systemctl restart mysqld
登录
mysql -uroot -ptgram123
赋予任何主机访问数据的权限(远程访问)
mysql> grant all privileges on *.* to 'root'@'%' identified by 'tgram123' with grant option;
Query OK, 0 rows affected (0.00 sec)
---刷新权限后退出
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
exit
重启mysql服务
systemctl restart mysqld
配置文件优化
修改mysql最大连接数
mysql> show variables like "max_connections";
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 151 |
+-----------------+-------+
1 row in set (0.01 sec)
--当processlist的数量大于查询到的max_connections时,就会出现too many connections的提示信息。
- 临时修改
mysql> set GLOBAL max_connections=1000;
- 永久修改
---找到 my.cnf 修改配置文件
vim /etc/my.cnf
--在[mysqld]下面添加
max_connections=2000
然后重新启动mysql立刻生效
systemctl restart mysqld
修改wait_timeout参数
- 永久修改
修改参数配置文件
vi /etc/my.cnf
[mysqld]
wait_timeout = 1800(单位秒)
#wait_timeout = 28800(默认是28800,8个小时)
interactive_timeout = 1800(单位秒)
#interactive_timeout = 28800(默认是28800,8个小时)
#增加以上两列即可,因为官方文档要求修改此参数必须同时修改interactive_timeout
查看数据库参数是否修改成功
Show variables like 'wait_timeout';
- 临时修改:
mysql -uroot -ptgram123
mysql> set global wait_timeout=1800;
Query OK,0 rows affected(0.00 sec)
mysql> set global interactive_timeout=1800;
mysql> show global variables like '%timeout%';
mysql> show variables like 'wait_timeout';
注意
必须要同时修改l级interactive_timeout和wait_timeout才能生效