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