Home  >  Article  >  Database  >  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
WBOYforward
2023-05-26 12:31:061400browse

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

3.Mysql depends on the libaio library

yum search libaio  # search for infoyum install libaio # install library

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

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/

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

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 &

The following step is optional

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

5. Configuration after installation

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

basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306

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

cp my-default.cnf /etc/my.cnf

Add mysql environment variable

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

6. Start mysql

service mysqld start

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  ]

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

7. Modify the root password:

Adopt

mysql -uroot -p

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

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;

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');

#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)

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!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete