1、下载Mysql包 1.1 进入官网选择社区版mysql mysql官网网址:MySQL 1.2 选择 MySQL CommUnity Server 下载 1.3 选择操作系统类型和MySQL版本 1.4 开始下载
1.4.1 linux中下载MySQL
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.30-linux-glibc2.12-x86_64.tar.xz
1 首先要将mysql包移动到到自定义的安装目录下
mv mysql-8.0.30-linux-glibc2.12-x86_64.tar.xz /usr/local/soft/
1.6.2 然后进行解压,注意这个文件是.xz文件
注意:-Jxvf 中的J为大写的
tar -Jxvf mysql-8.0.30-linux-glibc2.12-x86_64.tar.xz
我这里的文件是.xz文件,如果你下载的文件是**.tar.gz文件的话用 :tar -zxvf +文件命令
给解压后的文件重命名
mv mysql-8.0.30-linux-glibc2.12-x86_64.tar.xz mysql8
1| vim /etc/my.cnf
在my.cnf文件中加入以下配置:
[mysqld]# 设置3306端口port=3306# 设置mysql的安装目录basedir=/usr/local/soft/mysql8# 设置mysql数据库的数据的存放目录datadir=/usr/local/soft/mysql8/data# 允许最大连接数/max_connections=10000# 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统max_connect_errors=10# 服务端使用的字符集默认为UTF8#character-set-server=UTF8# 创建新表时将使用的默认存储引擎default-storage-engine=INNODB# 默认使用“mysql_native_passWord”插件认证default_authentication_plugin=mysql_native_password[mysql]# 设置mysql客户端默认字符集default-character-set=utf8[client]# 设置mysql客户端连接服务端时默认使用的端口port=3306default-character-set=utf8user=mysql
在mysql的安装目录下新建文件data
mkdir data
创建用户组并给用户组权限
[root@ecs-s6-medium-2-linux-20191122095023 mysql]# groupadd mysql[root@ecs-s6-medium-2-linux-20191122095023 mysql]# useradd -rg mysql mysql[root@ecs-s6-medium-2-linux-20191122095023 mysql]# chown -R mysql:mysql /usr/local/soft/mysql8/
初始化mysql数据库
记住mysql的初始密码
[mysql@wnode1 mysql8]$ cd support-files/[mysql@wnode1 support-files]$ lsmysqld_multi.server mysql-log-rotate mysql.server[mysql@wnode1 support-files]$ ./mysql.server startStarting MySQL SUCCESS![mysql@wnode1 support-files]$
[root@wnode1 mysql8]#[root@wnode1 mysql8]#[root@wnode1 mysql8]#[root@wnode1 mysql8]# ./bin/mysql -h 127.0.0.1 -u root -pEnter password:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 8Server version: 8.0.30 MySQL Community Server - GPLCopyright (c) 2000, 2022, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>
将root用户的密码设置为 123456
alter user 'root'@'localhost' identified by '123456';
注意当你mysql安装的路径不是/usr/local/mysql 时启动可能会报错
这时我们需要修改下mysql启动脚本的配置文件
[root@wnode1 mysql8]#[root@wnode1 mysql8]#[root@wnode1 mysql8]#[root@wnode1 mysql8]# su mysql[mysql@wnode1 mysql8]$ cd support-files/[mysql@wnode1 support-files]$ vim mysql.server
[mysql@wnode1 support-files]$ vim mysqld_multi.server
用root登录mysql: ./bin/mysql -h 127.0.0.1 -u root -p
切换到mysql数据库: use mysql
更改root的权限,允许其他IP地址登录: update user set host = "%" where user = "root";
查看表数据: select host, user from user;
刷新权限: flush privileges;
[root@ecs-s6-medium-2-linux-20191122095023 mysql-8.0]#[root@ecs-s6-medium-2-linux-20191122095023 mysql-8.0]# pwd/usr/local/mysql[root@ecs-s6-medium-2-linux-20191122095023 mysql-8.0]# ./bin/mysql -u root -pEnter password:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 9Server version: 8.0.18Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>mysql> use mysqlReading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedmysql>mysql> update user set host = '%' where user = 'root';Query OK, 1 row affected (0.00 sec)Rows matched: 1 Changed: 1 Warnings: 0mysql>mysql> select host, user from user;+-----------+------------------+| host | user |+-----------+------------------+| % | root || localhost | mysql.infoschema || localhost | mysql.session || localhost | mysql.sys |+-----------+------------------+4 rows in set (0.00 sec)mysql>mysql> flush privileges;Query OK, 0 rows affected (0.00 sec)mysql>————————————————版权声明:本文为CSDN博主「慧梦之旅」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。原文链接:Https://blog.csdn.net/qq_35330159/article/details/103236316
来源地址:https://blog.csdn.net/weixin_53366062/article/details/126636967
--结束END--
本文标题: Linux下安装mysql8.0
本文链接: https://lsjlt.com/news/396617.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-10-23
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0