MySQL8.0.22 安装
目录
Get MySQL
- With the command ldd –version to Check the glibc version for your Linux server

- Download the latest version of MySQL 8 from the URL: https://dev.mysql.com/downloads/mysql/ .
- Select Linux – Generic and OS version is Linux -Generic (glibc 2.17)(x86,64-bit)

- Upload the MySQL tar package to your server and saved the package to directory /usr/local.

- Verifying package integrity using MD5
[root@SGDLITVM0702 local]# md5sum mysql-8.0.22-linux-glibc2.17-x86_64-minimal.tar.xz
784fcd37010a05d85a18b4b779b52105 mysql-8.0.22-linux-glibc2.17-x86_64-minimal.tar.xz
![]()
Let’s start to install……
Create a mysql User and Group
If your system does not already have a user and group to use for running mysqld, you may need to create them. The following commands add the mysql group and the mysql user.
[root@SGDLITVM0702 local]# groupadd mysql
[root@SGDLITVM0702 local]# useradd -r -g mysql -s /bin/false mysql
![]()
Note: Because the user is required only for ownership purposes, not login purposes, the useradd command uses the -r and -s /bin/false options to create a user that does not have login permissions to your server host. Omit these options if your useradd does not support them.
Unpack the package
Unpack the distribution, which creates the installation directory. tar can uncompress and unpack the distribution if it has z option support:

The tar command creates a directory named mysql-VERSION-OS(mysql-8.0.22-linux-glibc2.17-x86_64-minimal).
Next, create a symbolic link to the installation directory created by tar:

Note: The ln command makes a symbolic link to the installation directory. This enables you to refer more easily to it as /usr/local/mysql. To avoid having to type the path name of client programs always when you are working with MySQL, you can add the /usr/local/mysql/bin directory to your PATH variable:
export PATH=$PATH:/usr/local/mysql/bin
Create data directory
Create a directory to initialize and save database, and change the permissions of the current mysql directory to mysql.
mkdir /data
ln -s /data data

Check if the system has its own MySQL installation

Check and Remove old config file

Create your own profile my.cnf


Check the initialize log:

Change the permissions like below:

Now start the mysql server:

Connect the MySQL server:

Change the password when first login:
ALTER USER 'root'@'localhost' IDENTIFIED BY ‘********‘;

Detail command line:
- groupadd mysql
- useradd -r -g mysql -s /bin/false mysql
- cd /usr/local
- tar xf mysql-8.0.22-linux-glibc2.17-x86_64-minimal.tar.xz
- ln -s mysql-8.0.22-linux-glibc2.17-x86_64-minimal mysql
- cd mysql
- mkdir /data
- ln -s /data data
- chown -R mysql:mysql /data
- chown -R mysql:mysql .
- rpm -qa | grep mysql
- rpm -qa | grep mariadb
- yum remove mariadb
- rpm -qa | grep mariadb
- bin/mysqld --help --verbose | grep my.cnf
- rm -rf /etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf
- bin/mysqld --initialize --user=mysql
- bin/mysql_ssl_rsa_setup
- chown -R root .
- chown -R mysql data
- bin/mysqld_safe --user=mysql &
- bin/mysql -u root -p
- ALTER USER 'root'@'localhost' IDENTIFIED BY '******';
Refer url : https://dev.mysql.com/doc/refman/8.0/en/binary-installation.html#binary-installation-layout
这篇博客介绍了如何在Linux系统上安装MySQL 8.0.22。首先,通过`ldd --version`检查GLIBC版本,然后从官网下载适合的MySQL安装包并验证其MD5校验值。接着,创建mysql用户和组,解压安装包,并设置数据目录。检查系统中是否存在旧的MySQL或MariaDB安装,移除它们。初始化MySQL并配置my.cnf文件,最后启动MySQL服务,并修改初次登录的root用户密码。
3023

被折叠的 条评论
为什么被折叠?



