当前位置:   article > 正文

MySQL5.7 压缩包安装_mysql-5.7.37-linux 百度云

mysql-5.7.37-linux 百度云

一、压缩包下载

压缩包下载路径:https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz

二、安装

2.1、解压缩

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

2.2、创建安装目录

mkdir /usr/local/mysql

将解压后的文件夹拷贝至安装目录/usr/lcoal/mysql/,并重命名为mysql-5.7

mv mysql-5.7.37-linux-glibc2.12-x86_64 /usr/local/mysql/mysql-5.7

2.3、创建相关目录

  1. mkdir /usr/local/mysql/mysql-5.7/data
  2. mkdir /usr/local/mysql/mysql-5.7/log
  3. touch /usr/local/mysql/mysql-5.7/log/mysqld.log

2.4、创建linux用户

  1. su root
  2. groupadd mysql #添加mysql组
  3. useradd -r -g mysql mysql #添加mysql用户

2.5、更改文件归属

  1. chown -R mysql /usr/local/mysql/mysql-5.7
  2. chgrp -R mysql /usr/local/mysql/mysql-5.7

2.6、初始化MySQL

  1. cd /usr/local/mysql/mysql-5.7
  2. bin/mysqld --user=mysql --basedir=/usr/local/mysql/mysql-5.7/ --datadir=/usr/local/mysql/mysql-5.7/data --initialize

输出如下信息,会生成一个临时登录密码

 root@ubuntu:/usr/local/mysql/mysql-5.7# bin/mysqld --user=mysql --basedir=/usr/local/mysql/mysql-5.7/ --datadir=/usr/local/mysql/mysql-5.7/data --initialize
2022-04-16T10:18:43.242411Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-04-16T10:18:43.417483Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-04-16T10:18:43.452197Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-04-16T10:18:43.512300Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 97f52ec0-bd6e-11ec-a319-000c29bea374.
2022-04-16T10:18:43.515493Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-04-16T10:18:44.181127Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2022-04-16T10:18:44.181190Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2022-04-16T10:18:44.181612Z 0 [Warning] CA certificate ca.pem is self signed.
2022-04-16T10:18:44.270207Z 1 [Note] A temporary password is generated for root@localhost: -62P&d,D8m,%

三、配置MySQL

3.1、修改配置文件

vim /etc/my.cnf

添加如下内容

  1. [mysqld]
  2. datadir=/usr/local/mysql/mysql-5.7/data
  3. basedir=/usr/local/mysql/mysql-5.7
  4. socket=/tmp/mysqld.sock
  5. user=mysql
  6. port=3306
  7. character-set-server=utf8
  8. skip-grant-tables
  9. symbolic-links=0
  10. [mysqld_safe]
  11. log-error=/var/log/mysqld.log
  12. pid-file=/var/run/mysqld/mysqld.pid
  13. [client]
  14. socket=/tmp/mysqld.sock

3.2、启动MySQL

  1. cd /usr/local/mysql/mysql-5.7/support-files
  2. sh mysql.server start

查看MySQL服务是否启动成功

  1. sh support-files/mysql.server status
  2. * MySQL running (6787)

3.3、配置环境变量

vim /etc/profile

添加如下内容

export PATH=$PATH:/usr/local/mysql/mysql-5.7/bin

使配置生效

source /etc/profile

3.4、允许root账号远程访问

先本地登录mysql,查询权限

  1. use mysql;
  2. select User,authentication_string,Host from user;

mysql> select  User,authentication_string,Host from user;
+---------------+-------------------------------------------+-----------+
| User          | authentication_string                     | Host      |
+---------------+-------------------------------------------+-----------+
| root          | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B | localhost |
| mysql.session | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | localhost |
| mysql.sys     | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | localhost |

设置权限

  1. GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root'
  2. flush privileges;

3.5、修改登录密码

  1. set password for root@'%'=password('123456');
  2. flush privileges;

四、安装过程中的问题及解决办法

4.1、初始化报错

mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory

解决办法:

yum install -y libaio.so.1

yum install -y libaio

4.2、修改权限报错

mysql> grant all on cactidb.* to dbuser@'localhost' identified by '123';

ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

解决办法:

先输入 flush privileges; 刷新一下权限表,再重新执行grant命令,就成功了

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/689442
推荐阅读
相关标签
  

闽ICP备14008679号