centos下安装mysql5.7.28

mysql下载地址:https://downloads.mysql.com/archives/community/

1.下载 解压

wget https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz
tar xzf mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz

2.移动mysql到对应目录

mv /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql

3.创建用户和组并赋权限

groupadd mysql
useradd -r -g mysql mysql
chown -R mysql:mysql mysql

4.配置mysql

mkdir -p /data/mysql
chown -R mysql:mysql /data/mysql
vim /etc/my.cnf
#录入一下内容
[mysqld]
bind-address=0.0.0.0
port=3306
user=mysql
basedir=/usr/local/mysql
datadir=/data/server/mysql
socket=/tmp/mysql.sock
log-error=/data/server/mysql/mysql.err
pid-file=/data/server/mysql/mysql.pid
#character config
character_set_server=utf8mb4
symbolic-links=0
explicit_defaults_for_timestamp=true

初始化数据库

/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/data/server/mysql/ --user=mysql --initialize

5.启动mysql

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
service mysql start

6.修改mysql密码 创建远程账户

/usr/local/mysql/bin/mysql -u root -p
SET PASSWORD=PASSWORD('root');
flush privileges;

use mysql;
create user 'test001' identified by '123456';
grant all privileges on *.* to 'test001'@'%' identified by '123456' with grant option;
 flush privileges;

7.修改mysql为全局命令

vim /etc/profile
末尾加入
export PATH=$PATH:/data/server/go/bin
export GOPATH=/data/web/go/
export GOROOT=/data/server/go
export PATH=$PATH:/data/server/php/bin
export PATH=$PATH:/usr/local/mysql/bin

然后source /etc/profile

期间可能报两个错误 一个

/usr/local/mysql/bin/mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory
yum install -y numactl  解决
(dnf upgrade libmodulemd解决centos8 yum报错问题)


error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
yum install -y libncurses*  解决

你可能感兴趣的:(centos下安装mysql5.7.28)