centos stream8二进制安装 mysql 5.7
上传mysql二进制文件到/data/software/mysql-5.7.43-linux-glibc2.12-x86_64.tar.gz
创建目录结构
mkdir -p /data/app/mysql mkdir -p /data/appdata/mysql mkdir -p /data/logs/mysql mkdir -p /data/tmp/mysql
添加用户、用户组
groupadd mysql
useradd -r -g mysql mysql -s /sbin/nologin
设置目录权限
chown -R mysql:mysql /data/app/mysql chmod 750 /data/app/mysql chown -R mysql:mysql /data/appdata/mysql chmod 750 /data/appdata/mysql chown -R mysql:mysql /data/logs/mysql chmod 777 /data/logs/mysql chown -R mysql:mysql /data/tmp/mysql chmod 750 /data/tmp/mysql
创建配置文件
cat >/etc/my.cnf <<EOF [mysqld_safe] [client] port = 3306 socket = /data/tmp/mysql/mysql.sock [mysqld] server_id = 1 port = 3306 user = mysql basedir = /data/app/mysql datadir = /data/appdata/mysql pid-file = /data/tmp/mysql/mysql.pid socket = /data/tmp/mysql/mysql.sock log_error = /data/logs/mysql/mysql-error.log default_storage_engine = InnoDB innodb-file-per-table = 1 skip-external-locking open_files_limit = 65535 [mysql] auto-rehash prompt=\\u@\\d \\R:\\m mysql> EOF
解压mysql-5.7.43-linux-glibc2.12-x86_64.tar.gz
tar -zxvf /data/software/mysql-5.7.43-linux-glibc2.12-x86_64.tar.gz -C /data/app
重命名
mv /data/app/mysql-5.7.43-linux-glibc2.12-x86_64 /data/app/mysql
进去mysql目录
cd /data/app/mysql
初始化mysql
./bin/mysqld --initialize-insecure --user=mysql --basedir=/data/app/mysql --datadir=/data/appdata/mysql
设置mysql服务
cp ./support-files/mysql.server /etc/init.d/mysqld
service mysqld start
chkconfig --add mysqld
chkconfig mysqld on
修改密码并设置成远程访问
ALTER USER `root`@`localhost` IDENTIFIED BY '123456';
RENAME USER `root`@`localhost` TO `root`@`%`;
添加到环境变量
echo "PATH=/data/app/mysql/bin:/data/app/mysql/lib:\$PATH">>/etc/profile.d/myprofile.sh
source /etc/profile.d/myprofile.sh
启动mysql报类似错误:error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
ln -s /usr/lib64/libtinfo.so.6 /usr/lib64/libtinfo.so.5 ln -s /usr/lib64/libncurses.so.6 /usr/lib64/libncurses.so.5