Home > Database > Mysql Tutorial > How to quickly install MySQL 5.7.17 under CentOS 6.5

How to quickly install MySQL 5.7.17 under CentOS 6.5

WBOY
Release: 2023-05-26 12:31:06
forward
1428 people have browsed it

CentOS 6.5下怎么快速安装MySQL 5.7.17

1. Download the installation package

Download the latest mysql installation package mysql-5.7.17-Linux-glibc2.5-x86_64 from the MySQL official website. tar.gz

Note, be sure to download .tar.gz, do not download the .tar package

Upload the installation package to the /opt directory:

2. Check whether the library file exists and delete it if it exists

[root@host-172-16-5-7 ~]# rpm -qa | grep mysqlmysql-libs-5.1.73-3.el6_5.x86_64
[root@host-172-16-5-7 ~]# rpm -e mysql-libs-5.1.73-3.el6_5.x86_64 --nodeps/sbin/ldconfig: File /usr/lib64/libpq.so.5.8 is empty, not checked.
[root@host-172-16-5-7 ~]# rpm -qa | grep mysql
Copy after login

3.Mysql depends on the libaio library

yum search libaio  # search for infoyum install libaio # install library
Copy after login

4. Perform the following steps to install Mysql

groupadd mysql
useradd -r -g mysql -s /bin/false mysqlcd /usr/localtar -zxvf /opt/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz -C /opt/
ln -s /opt/mysql-5.7.17-linux-glibc2.5-x86_64 mysqlcd mysql
mkdir mysql-files
chmod 750 mysql-files
chown -R mysql .
chgrp -R mysql .
bin/mysqld --initialize --user=mysql
Copy after login

If an error is reported in this step As follows:

[ERROR] –initialize specified but the data directory has files in it. Aborting.

Solution:

rm -rf /var/lib/mysql/
Copy after login

Re-execute the above command, prompt to generate Create a temporary password:

2017-01-03T09:12:33.748807Z 1 [Note] A temporary password is generated for root@localhost: =*-gFoje>1Pr
Copy after login

Executing this step should generate a data directory. If it is not generated, it must be because there is already installed mysql in the system. Uninstall it according to step 2, and then execute it again

bin/mysqld --initialize --user=mysql
bin/mysql_ssl_rsa_setup
chown -R root .
chown -R mysql data mysql-files
bin/mysqld_safe --user=mysql &
Copy after login

The following step is optional

cp support-files/mysql.server /etc/init.d/mysqld
Copy after login

5. Configuration after installation

Modify /usr/local/mysql/support-files/my-default.cnf

basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
Copy after login

After modification, copy a copy to the /etc/ directory and rename it to my.cnf

cp my-default.cnf /etc/my.cnf
Copy after login

Add mysql environment variable

vim /etc/profileexport MYSQL_HOME=/usr/local/mysqlexport PATH=$MYSQL_HOME/bin:$PATHsource /etc/profile
Copy after login

6. Start mysql

service mysqld start
Copy after login

Start successfully:

[root@ambari support-files]# service mysqld startStarting MySQL.Logging to '/usr/local/mysql/data/ambari.err'.
.                                                          [  OK  ]
[root@ambari support-files]# service mysqld statusMySQL running (8010)                                       [  OK  ]
Copy after login

When executing this step, the startup may not be successful. The error message is as follows:

MySQL: Starting MySQL….. ERROR! The server quit without updating PID file
Copy after login

7. Modify the root password:

Adopt

mysql -uroot -p
Copy after login

When logging in, enter the root password recorded earlier, and it prompts that the password is incorrect. We have no choice but to change the root password ourselves.

The specific steps are as follows:

step1:

vim /etc/my.cnf
Copy after login

Add a line skip-grant-tables under [mysqld]

step2:

service mysqld restart After that, you can directly use mysql to enter

mysql> update mysql.user set authentication_string=password('root') where user='root' and Host = 'localhost';
mysql> flush privileges;
mysql> quit;
Copy after login

step3:

Restore the /etc/my.cnf file and restart mysql:service mysqld restart. This time you can Use mysql -u root -p’root’ to enter

step4:

After entering sql, change the password once through the following command, otherwise you cannot perform other operations. :

mysql> SET PASSWORD = PASSWORD('mysql');
Copy after login

#step5:

Execute show databases on the sql console; the results are as follows:

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)
Copy after login

The above is the detailed content of How to quickly install MySQL 5.7.17 under CentOS 6.5. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template