signed

QiShunwang

“诚信为本、客户至上”

mysql-5.7.32安装

2021/6/3 16:08:40   来源:

mysql-5.7.32安装

解压缩

tar -zxvf mysql-5.7.32-linux-glibc2.12-x86_64.tar.gz

修改文件名

mv  mysql-5.7.32-linux-glibc2.12-x86_64  mysql-5.7.32

创建data目录

cd /usr/local/mysql-5.7.32
mkdir data

初始化数据库

cd bin
./mysqld --initialize --datadir=/usr/local/mysql-5.7.32/data/   --basedir=/usr/local/mysql-5.7.32   --user=mysql

记住下面的root密码,一会访问数据库会用到
在这里插入图片描述
在data目录下创建my.cnf文件

 cd /usr/local/mysql-5.7.32/data/
 vim /etc/my.cnf

复制下面内容到my.cnf文件中

[client]
port     =3307
socket   =/usr/local/mysql-5.7.32/data/mysql.sock
default-character-set=utf8
[mysqld]
port     =3307
socket   =/usr/local/mysql-5.7.32/data/mysql.sock
datadir  =/usr/local/mysql-5.7.32/data
log-error=/usr/local/mysql-5.7.32/data/error.log
character-set-server=utf8
lower_case_table_names=1
autocommit =1

设置data目录路径

 cd /usr/local/mysql-5.7.32/bin/
./mysql_ssl_rsa_setup --datadir  =/usr/local/mysql-5.7.32/data/

为mysql用户设置mysql-5.7.32的访问权限

 chown -R mysql.mysql /usr/local/mysql-5.7.32

后台启动mysql

 ./mysqld_safe &

访问数据库,密码输入上面生成的密码

 ./mysql  -uroot -p

在这里插入图片描述
重新设置root用户的密码,并设置远程访问

alter  user 'root'@'localhost'  identified by  '123456';
grant  all privileges on *.* to root@'%' identified by  '123456';
flush  privileges;