本文以mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz 数据库来安装,安装文件自行去官网下载,
安装过程
1,上传文件到mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz到/usr/local目录下,以下操作都在/usr/local下操作。
2,解压文件 > tar –xvf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz
3,修改解压出来的文件名称 > mv mysql-5.7.18-linux-glibc2.5-x86_64 mysql
4,创建数据库data目录 > mkdir /usr/local/mysql/data
5,创建mysql用户组 > groupadd mysql
6,把用户添加组 > useradd -r -g mysql mysql
7,把目录权限给这个组: > chown -R mysql.mysql /usr/local/mysql/
8,初始化数据库 > mysql/bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
9,上传my-default.cnf文件到/usr/local/mysql/support-files/目录下,执行修改权限命令
10,> chown -R root mysql/support-files/my-default.cnf
11,> chown -R mysql mysql/support-files/my-default.cnf
12,> chgrp -R mysql mysql/support-files/my-default.cnf
13,复制配置文件> cp -a mysql/support-files/my-default.cnf /etc/my.cnf
14,> chmod 644 /etc/my.cnf
15,> cp -a mysql/support-files/mysql.server /etc/init.d/mysqld
16,启动mysql,> service mysqld start
17,查看初始化自动生成的密码> cat /root/.mysql_secret
18,登录MySQL > mysql/bin/mysql -u root –p (密码是上面的自动生成的初始化密码)
19,修改密码 > SET PASSWORD FOR ‘root’@localhost = PASSWORD (‘密码自行定义’);
20,修改所有IP都能访问 > grant all privileges on *.* to ‘root’@’%’ identified by ‘密码’;
21,> flush privileges;
my.cnf文件内容根据自己需求自行定义,此处为方便运行起来简单粘贴出内容:
innodb_buffer_pool_size = 1024M
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
socket = /tmp/mysql.sock
character-set-server = utf8
max_connections=10000
max_allowed_packet=20M
sql_mode=STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
阿里云centos 7.8 按照报错
/usr/local/mysql/bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
解决方法
yum install libaio-devel.x86_64