怎么在Linux环境中安装MySQL8.0.11

47次阅读
没有评论

共计 2796 个字符,预计需要花费 7 分钟才能阅读完成。

自动写代码机器人,免费开通

这期内容当中丸趣 TV 小编将会给大家带来有关怎么在 Linux 环境中安装 MySQL8.0.11,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。

1. 去官网下载安装包

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 mysql
useradd -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_db
chmod 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 libnuma
yum -y install numactl
yum 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/mysql
chmod +x /etc/init.d/mysql

添加到系统服务

chkconfig --add mysql
cp -a ./support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/rc.d/init.d/mysqld
chkconfig --add mysqld

检查服务是否生效

chkconfig –list mysqld

9. 配置全局环境变量

编辑 / etc/profile 文件

# vi /etc/profile

在 profile 文件底部添加如下两行配置,保存后退出

export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib
export PATH

设置环境变量立即生效

source /etc/profile

10. 启动 MySQL 服务

service mysql start

查看初始密码

cat /root/.mysql_secret

11. 登录 MySQL

mysql -uroot - p 密码

修改密码:

SET PASSWORD FOR root @localhost=PASSWORD(123456 #对应的换成你自己的密码即可了。

怎么在 Linux 环境中安装 MySQL8.0.11

12 设置可以远程登录

mysql use mysql
mysql update user set host= %  where user= root  limit 1;

刷新权限

mysql flush privileges;

然后检查 3306 端口是否开放

netstat -nupl|grep 3306

开放 3306 端口

firewall -cmd –permanent –add-prot=3306/tcp

重启防火墙

firewall -cmd –reload

上述就是丸趣 TV 小编为大家分享的怎么在 Linux 环境中安装 MySQL8.0.11 了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注丸趣 TV 行业资讯频道。

向 AI 问一下细节

正文完
 
丸趣
版权声明:本站原创文章,由 丸趣 2023-12-04发表,共计2796字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)