首页 > 数据库 > MySQL > 正文

Linux下安装MySQL8.0.11的教程

2024-07-24 12:41:42
字体:
来源:转载
供稿:网友

1. 去官网下载安装包

下载链接:点击打开链接

https://dev.mysql.com/downloads/mysql/

如果你的系统是32位选择第一个,64位选择第二个

也可以用wget 下载

wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.11-linux-glibc2.12-i686.tar.gz

解压文件

tar -zxvf mysql-8.0.11-linux-glibc2.12-i686.tar.gz

2 移动压缩包到usr/local目录下,并重命名文件

mv /root/mysql-8.0.11-linux-glibc2.12-i686 /usr/local/mysql

3.在MySQL根目录下新建一个文件夹data,用于存放数据

mkdir data

4.创建 mysql 用户组和 mysql 用户

groupadd mysqluseradd -g mysql mysql

5.改变 mysql 目录权限

chown -R mysql.mysql /usr/local/mysql/ 或者 chown -R mysql . chgrp -R mysql .

注意最后有一点

6.初始化数据库

创建mysql_install_db安装文件

mkdir mysql_install_dbchmod 777 ./mysql_install_db

初始化

bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data //初始化数据库

或者

/usr/local/mysql/bin/mysqld --initialize --user=mysql/usr/local/mysql/bin/mysqld --initialize --user=mysql/usr/local/mysql/bin/mysqld (mysqld 8.0.11) initializing of server in progress as process 5826 [Server] A temporary password is generated for root@localhost: twi=Tlsi<0O!/usr/local/mysql/bin/mysqld (mysqld 8.0.11) initializing of server has completed

记录好自己的临时密码:

twi=Tlsi<0O!

这里遇到了问题没有libnuma.so.1

zsh: command not found: mysqld
./bin/mysqld --initialize
./bin/mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory

2018-04-29 17:06:30 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2018-04-29 17:06:30 [ERROR] Can't locate the language directory.

需要安装 libnuma

yum install libnumayum -y install numactlyum install libaio1 libaio-dev

安装文件

7.mysql配置

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

修改my.cnf文件

vim /etc/my.cnf

[mysqld] basedir = /usr/local/mysql  datadir = /usr/local/mysql/data socket = /usr/local/mysql/mysql.sock character-set-server=utf8 port = 3306 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES [client] socket = /usr/local/mysql/mysql.sock default-character-set=utf8

esc保存

:wq 退出

8建立MySQL服务

cp -a ./support-files/mysql.server /etc/init.d/mysqld

cp mysql.server /etc/init.d/mysqlchmod +x /etc/init.d/mysql
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表