mysql 8.0.18 安装配置方法图文教程(linux)

编程学习 2021-07-05 14:37www.dzhlxh.cn编程入门
这篇文章主要介绍了linux下mysql 8.0.18 安装配置方法图文教程,文中安装步骤介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

本文记录了linux mysql 8.0.18 安装配置图文教程,供大家参考,具体内容如下

1、官网安装包

2、我这里通过xftp将安装包上传至Linux服务器

3.解压

解压命令:tar -xvf mysql-8.0.18-linux-glibc2.12-x86_64.tar

继续解压需要的那一个

命令: tar -xvf mysql-8.0.18-linux-glibc2.12-x86_64.tar.xz

重命名并移动到合适的路径

重命名 : mv mysql-8.0.18-linux-glibc2.12-x86_64 mysql

移动:


4.在/usr/local/mysql下创建data文件夹

# mkdir data

5.初始化数据库,自动生成密码 需记录 等下要用

# bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

ps:中间遇到一个坑,初始化数据库时候报了错

具体错误为:bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory

解决方法为:yum install libaio-devel.x86_64 原因是缺少了libaio这个东西 安装就完事了

再次执行初始化命令

得到初始化密码,需要记下,一会会用到

6.修改/usr/local/mysql 当前目录的用户

# chown -R root:root ./
# chown -R mysql:mysql data

7.复制my-default.cnf这个文件到etc/my.cnf去

具体命令为:

# cd support-files/
# touch my-default.cnf
# chmod 777 ./my-default.cnf 
# cd ../
# cp support-files/my-default.cnf /etc/my.cnf

8.完了之后配置my.cnf

vim /etc/my.cnf

内容:

[mysqld]

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
socket = /tmp/mysql.sock
log-error = /usr/local/mysql/data/error.log
pid-file = /usr/local/mysql/data/mysql.pid
tmpdir = /tmp
port = 5186
#lower_case_table_names = 1
# server_id = .....
# socket = .....
#lower_case_table_names = 1
max_allowed_packet=32M
default-authentication-plugin = mysql_native_password
#lower_case_file_system = on
#lower_case_table_names = 1
log_bin_trust_function_creators = ON
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M 

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

如果后期mysql运行报错,可以直接到log-error = /usr/local/mysql/data/error.log目录下直接查看错误日志

命令:cat /usr/local/mysql/data/error.log

9.开机自启,进入/usr/local/mysql/support-files进行设置

# cd support-files/
# cp mysql.server /etc/init.d/mysql 
# chmod +x /etc/init.d/mysql

10.注册服务

# chkconfig --add mysql

11.查看是否成功

12.etc/ld.so.conf要配置路径,不然报错

# vim /etc/ld.so.conf

添加如下内容:

/usr/local/mysql/lib

13.配置环境变量

# vim /etc/profile
# source /etc/profile

添加如下内容:

#MYSQL ENVIRONMENT
export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib

14.登录 需要用到上面的生成的密码

#启动mysql服务
[root@localhost bin]# service mysql start
Starting MySQL.Logging to '/usr/local/mysql/data/error.log'.
.. SUCCESS! 
[root@localhost bin]# 
 
#修改mysql密码
mysql> alter user 'root'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.02 sec)
mysql> 

ps:第二个坑,在启动时出现错误 详情为:
Starting MySQL...The server quit without updating PID file [FAILED]cal/mysql/data/mysql.pid).

该错误翻了一下午,绕了一大圈,最终问题是my.cnf文件配置问题,千万不能以为加了#就是注释掉了,自己检查了n遍,觉得没有错,结果就是不行,没有办法找了一份另一台服务器的my.cnf配置,复制替换稍加修改,解决问题。

大功告成!可以使用可视化工具进行数据库连接了。

安装完成。

精彩专题分享:

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持狼蚁SEO。

Copyright © 2016-2025 www.dzhlxh.cn 金源码 版权所有 Power by

网站模板下载|网络推广|微博营销|seo优化|视频营销|网络营销|微信营销|网站建设|织梦模板|小程序模板