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

所属分类: 数据库 / Mysql 阅读数: 1771
收藏 0 赞 0 分享

本文记录了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配置,复制替换稍加修改,解决问题。

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

安装完成。

精彩专题分享:

mysql不同版本安装教程

mysql5.7各版本安装教程

mysql5.6各版本安装教程

mysql8.0各版本安装教程

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

更多精彩内容其他人还在看

mysql found_row()使用详解

在参考手册中对found_rows函数的描述是: it is desirable to know how many rows the statement would have returned without the LIMIT. 也就是说,它返回值是如果SQL语句没有加LI
收藏 0 赞 0 分享

很全面的MySQL处理重复数据代码

这篇文章主要为大家详细介绍了MySQL处理重复数据的实现代码,如何防止数据表出现重复数据及如何删除数据表中的重复数据,感兴趣的小伙伴们可以参考一下
收藏 0 赞 0 分享

图文详解Ubuntu下安装配置Mysql教程

这篇文章主要以图文结合的方式详细为大家介绍了Ubuntu安装配置Mysql的实现步骤,感兴趣的小伙伴们可以参考一下
收藏 0 赞 0 分享

Ubuntu下mysql安装和操作图文教程

这篇文章主要为大家详细分享了Ubuntu下mysql安装和操作图文教程,喜欢的朋友可以参考一下
收藏 0 赞 0 分享

Linux/UNIX和Window平台上安装Mysql

这篇文章主要为大家详细介绍了Linux/UNIX和Window两个系统上采用命令安装Mysql的方法,感兴趣的小伙伴们可以参考一下
收藏 0 赞 0 分享

忘记MySQL的root密码该怎么办

忘记密码总是一件令人头疼的事情,当我们忘记了MySQL的root密码该怎么办?本文给出解决方法,感兴趣的小伙伴们可以参考一下
收藏 0 赞 0 分享

Mysql存储引擎MyISAM的常见问题(表损坏、无法访问、磁盘空间不足)

这篇文章主要介绍了Mysql存储引擎MyISAM的常见问题,针对表损坏、无法访问、磁盘空间不足等问题进行解决,感兴趣的小伙伴们可以参考一下
收藏 0 赞 0 分享

VS2013连接MySQL5.6成功案例一枚

这篇文章主要为大家分享了VS2013连接MySQL5.6成功案例一枚,很有实用性,感兴趣的小伙伴们可以参考一下
收藏 0 赞 0 分享

Windows下mysql修改root密码的4种方法

这篇文章主要为大家详细介绍了windows下mysql修改root密码的4种方法,大家可以根据的自己的实际情况进行选择,感兴趣的小伙伴们可以参考一下
收藏 0 赞 0 分享

mysql Sort aborted: Out of sort memory, consider increasing server sort buffer size的解决方法

这篇文章主要介绍了mysql Sort aborted: Out of sort memory, consider increasing server sort buffer size的解决方法,需要的朋友可以参考下
收藏 0 赞 0 分享
查看更多