Linux - several ways to install MySQL

Little Love 'Moon 2022-08-06 08:26:30 阅读数:481

linuxwaysinstallmysql

一、 yum在线安装

1、 下载并安装MySQL官方的 Yum Repository

 [[email protected] ~]# dnf install https://repo.mysql.com//mysql80-community-release-el9-1.noarch.rpm

2、 直接安装mysql-server

[[email protected] ~]# dnf install mysql-server

3、 启动服务

 [[email protected] ~]# systemctl start mysqld.service

4、 查看临时密码

 [[email protected] ~]# grep 'temporary password' /var/log/mysqld.log

5、 使用临时密码进行登录

 [[email protected] ~]# mysql -uroot -p
Enter password: 临时密码
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 11 Server version: 8.0.30 Copyright (c) 2000, 2022, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>

6、 如果需要更改密码,则使用下面语句

 mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
更改之后,you can log in with the new password.

If the log file is not found,则可以查找 /var/log/mysql/mysqld.log,如果没有密码,The default is an empty password.

二、 本地rpm安装

mysql-8.0.30-1.el9.x86_64.rpm-bundle.tar可私信我获取

 [[email protected] ~]#tar -xvf mysql-8.0.30-1.el9.x86_64.rpm-bundle.tar

解压完成后,

[[email protected] ~]# ll
total 1404324
-rw-------. 1 root root 1263 Aug 1 15:28 anaconda-ks.cfg
-rw-r--r--. 1 root root 719001600 Aug 1 15:58 mysql-8.0.30-1.el9.x86_64.rpm-bundle.tar
-rw-r--r--. 1 7155 31415 3916868 Jul 7 16:00 mysql-community-client-8.0.30-1.el9.x86_64.rpm
-rw-r--r--. 1 7155 31415 26442246 Jul 7 16:00 mysql-community-client-debuginfo-8.0.30-1.el9.x86_64.rpm
-rw-r--r--. 1 7155 31415 1418745 Jul 7 16:00 mysql-community-client-plugins-8.0.30-1.el9.x86_64.rpm
-rw-r--r--. 1 7155 31415 1709331 Jul 7 16:00 mysql-community-client-plugins-debuginfo-8.0.30-1.el9.x86_64.rpm -rw-r--r--. 1 7155 31415 547247 Jul 7 16:00 mysql-community-common-8.0.30-1.el9.x86_64.rpm
-rw-r--r--. 1 7155 31415 4776730 Jul 7 16:01 mysql-community-debuginfo-8.0.30-1.el9.x86_64.rpm
-rw-r--r--. 1 7155 31415 19086325 Jul 7 16:01 mysql-community-debugsource-8.0.30-1.el9.x86_64.rpm
-rw-r--r--. 1 7155 31415 2226982 Jul 7 16:01 mysql-community-devel-8.0.30-1.el9.x86_64.rpm
-rw-r--r--. 1 7155 31415 2255475 Jul 7 16:01 mysql-community-icu-data-files-8.0.30-1.el9.x86_64.rpm
-rw-r--r--. 1 7155 31415 1523965 Jul 7 16:02 mysql-community-libs-8.0.30-1.el9.x86_64.rpm
-rw-r--r--. 1 7155 31415 2366903 Jul 7 16:02 mysql-community-libs-debuginfo-8.0.30-1.el9.x86_64.rpm
-rw-r--r--. 1 7155 31415 50009730 Jul 7 16:02 mysql-community-server-8.0.30-1.el9.x86_64.rpm
-rw-r--r--. 1 7155 31415 21184990 Jul 7 16:02 mysql-community-server-debug-8.0.30-1.el9.x86_64.rpm
-rw-r--r--. 1 7155 31415 133498631 Jul 7 16:02 mysql-community-server-debug-debuginfo-8.0.30-1.el9.x86_64.rpm
-rw-r--r--. 1 7155 31415 168345073 Jul 7 16:03 mysql-community-server-debuginfo-8.0.30-1.el9.x86_64.rpm
-rw-r--r--. 1 7155 31415 261380651 Jul 7 16:04 mysql-community-test-8.0.30-1.el9.x86_64.rpm
-rw-r--r--. 1 7155 31415 18294573 Jul 7 16:04 mysql-community-test-debuginfo-8.0.30-1.el9.x86_64.rpm

使用dnf进行安装

 [[email protected] ~]# dnf localinstall mysql-community-server-8.0.30-1.el9.x86_64.rpm \ mysql-community-client-8.0.30-1.el9.x86_64.rpm \ mysql-community-common-8.0.30-1.el9.x86_64.rpm \ mysql-community-icu-data-files-8.0.30-1.el9.x86_64.rpm \ mysql-community-libs-8.0.30-1.el9.x86_64.rpm \ mysql-community-client-plugins-8.0.30-1.el9.x86_64.rpm

Other operations are the same as warehouse installation

三、 源码安装

 [[email protected] ~]# mkdir /mysql [[email protected] ~]# mv mysql-boost-8.0.29.tar.gz /mysql/ [[email protected] ~]# cd /mysql/ [[email protected] mysql]# tar xvf mysql-boost-8.0.29.tar.gz

解压完成后

[[email protected] mysql]# cd mysql-8.0.29/
[[email protected] mysql-8.0.29]# groupadd mysql [[email protected] mysql-8.0.29]# useradd -r -g mysql -s /bin/false mysql
[[email protected] mysql-8.0.29]# mkdir bld
[[email protected] mysql-8.0.29]# cd bld/
[[email protected] bld]# dnf install cmake gcc gcc-c++ [[email protected] bld]# yum install gcc-toolset-11-gcc gcc-toolset-11-gcc-c++ gcc-toolset-11-binutils ncurses-devel libtirpc-devel

注意:The file local repository does not have,需要自行下载

[[email protected] bld]# rpm -i rpcgen-1.3.1-4.el8.x86_64.rpm

开始cmake

[[email protected] bld]# cmake .. -DDOWNLOAD_BOOST=1 -DWITH_BOOST=../boost/boost_1_77_0/

完成后,in the virtual machine terminalmake

 [[email protected] bld]# make;make install
版权声明:本文为[Little Love 'Moon]所创,转载请带上原文链接,感谢。 https://javamana.com/2022/218/202208060817332319.html