当前位置:   article > 正文

Linux安装mysql8.0.24_mysql ver 8.0.24版本linux下载安装教程

mysql ver 8.0.24版本linux下载安装教程

1、安装环境准备

  1. # 检测是否安装过mysql
  2. rpm -qa | grep mysql
  3. # 删除命令
  4. rpm -e --nodeps mysql-libs-对应版本

下载对应mysql安装包:mysql-8.0.24-el7-x86_64.tar.gz

对应linux系统版本:CentOs 7.x86_64

用root创建用户mysql:

  1. groupadd -g 1510 mysql
  2. useradd -u 1511 -g mysql -d /home/ap/mysql mysql
  3. echo "想设置的密码" |passwd --stdin mysql

查看并重新卸载mariadb

  1. rpm -qa | grep mariadb
  2. rpm -e --nodeps mariadb-libs-对应版本
  3. yum install libaio
  4. yum -y install numactl

例如:

2、安装开始

(1)、用mysql用户上传mysql安装包到对应mysql文件夹下并执行解压;

  1. tar -zxvf mysql-8.0.24-el7-x86_64.tar.gz
  2. #结束后执行
  3. mv mysql-8.0.24-el7-x86_64/* ./
  4. rm -rf mysql-8.0.24-el7-x86_64
  5. #创建mysqldata目录
  6. mkdir /home/ap/mysql/mysqldata

(2)、用root用户创建/etc/my.cnf,对应如下内容:

  1. mysqld]
  2. # Remove leading # and set to the amount of RAM for the most important data
  3. # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
  4. # innodb_buffer_pool_size = 128M
  5. # Remove leading # to turn on a very important data integrity option: logging
  6. # changes to the binary log between backups.
  7. # log_bin
  8. # These are commonly set, remove the # and set as required.
  9. basedir = /home/ap/mysql
  10. datadir = /home/ap/mysql/mysqldata
  11. # socket = /tmp/mysql.sock
  12. log-error = /home/ap/mysql/mysqldata/error.log
  13. pid-file = /home/ap/mysql/mysqldata/mysql.pid
  14. port = 3306
  15. #lower_case_table_names = 1
  16. # server_id = .....
  17. # socket = .....
  18. #lower_case_table_names = 1
  19. max_allowed_packet=32M
  20. character-set-server=UTF8MB4
  21. default-storage-engine=INNODB
  22. default-authentication-plugin = mysql_native_password
  23. #lower_case_file_system = on
  24. #lower_case_table_names = 1
  25. log_bin_trust_function_creators = ON
  26. # Remove leading # to set options mainly useful for reporting servers.
  27. # The server defaults are faster for transactions and fast SELECTs.
  28. # Adjust sizes as needed, experiment to find the optimal values.
  29. # join_buffer_size = 128M
  30. # sort_buffer_size = 2M
  31. # read_rnd_buffer_size = 2M
  32. #sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

开机自启,进入/home/ap/mysql/support-files进行设置

  1. cd support-files/
  2. cp mysql.server /etc/init.d/mysql
  3. chmod +x /etc/init.d/mysql
  4. ln -s /home/ap/mysql/bin/mysql /usr/bin
  1. vim /etc/ld.so.conf
  2. # 添加如下内容:
  3. /home/ap/mysql/lib
  4. # 配置环境变量
  5. vim /etc/profile 添加如下内容
  6. export PATH=$PATH:/home/ap/mysql/bin:/home/ap/mysql/lib
  7. #结束生效
  8. source /etc/profile

 

  1. # 初始化数据库,mysql的bin目录下的mysqld命令
  2. /home/ap/mysql/bin/mysqld --initialize --user=root --basedir=/home/ap/mysql --datadir=/home/ap/mysql/mysqldata

 在/home/ap/mysql/mysqldata/error.log里查看root密码(对应root@localhost:后面的字符串):

 重置密码:

  1. alter user 'root'@'localhost' identified by '需要的密码';
  2. flush privileges;
  3. quit

3、允许远程登录设置

查看用户信息:

授权用户:

  1. CREATE USER 'root'@'%' IDENTIFIED BY '000000';
  2. GRANT ALL ON *.* TO 'root'@'%' WITH GRANT OPTION;
  3. alter user 'root'@'%' identified with mysql_native_password by '自定义';

重启mysql生效

 service mysql restart

远程连接测试成功

对于远程连接失败的排查提示(以华为云为例):

本地防火墙是否关闭;

网络ping不同解决办法,可参考引用https://support.huaweicloud.com/hecs_faq/hecs_faq_0604.html

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

闽ICP备14008679号