How to install mysql5.7.16 database in Linux 6.3How to install mysql5.7.16 database
This article mainly introduces how to install the mysql5.7.16 database in Linux 6.3. it has a certain reference value, and interested friends can refer to it. I hope you will gain a lot after reading this article.
1. Download the installation package
Http://dev.mysql.com/downloads/
two。 Check whether the library file exists, if deleted.
[root@QuDaoMysql mysql] # rpm-qa | grep mysql
Mysql-5.1.61-4.el6.x86_64
Qt-mysql-4.6.2-24.el6.x86_64
Mysql-server-5.1.61-4.el6.x86_64
Mysql-libs-5.1.61-4.el6.x86_64
Mysql-devel-5.1.61-4.el6.x86_64
[root@QuDaoMysql mysql] #
[root@QuDaoMysql mysql] # rpm-e mysql-5.1.61-4.el6.x86_64-nodeps
[root@QuDaoMysql mysql] # rpm-e qt-mysql-4.6.2-24.el6.x86_64-nodeps
[root@QuDaoMysql mysql] # rpm-e mysql-server-5.1.61-4.el6.x86_64-nodeps
[root@QuDaoMysql mysql] # rpm-e mysql-libs-5.1.61-4.el6.x86_64-nodeps
[root@QuDaoMysql mysql] # rpm-e mysql-devel-5.1.61-4.el6.x86_64-nodeps
[root@QuDaoMysql mysql] #
3. Check whether mysql groups and users exist, if not created.
[root@QuDaoMysql mysql] # cat / etc/group | grep mysql
Mysql:x:27:
[root@QuDaoMysql mysql] # cat / etc/passwd | grep mysql
Mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/bash
Pay attention to the installation sequence
Rpm-ivh mysql-community-common-5.7.16-1.el6.x86_64.rpm
Rpm-ivh mysql-community-libs-5.7.16-1.el6.x86_64.rpm
Rpm-ivh mysql-community-client-5.7.16-1.el6.x86_64.rpm
Rpm-ivh mysql-community-server-5.7.16-1.el6.x86_64.rpm
[root@QuDaoMysql _ rpminstall] # rpm-ivh mysql-community-common-5.7.16-1.el6.x86_64.rpm
Warning: mysql-community-common-5.7.16-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... # [100%]
1:mysql-community-common # # [100%]
[root@QuDaoMysql _ rpminstall] # rpm-ivh mysql-community-libs-5.7.16-1.el6.x86_64.rpm
Warning: mysql-community-libs-5.7.16-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... # [100%]
1:mysql-community-libs # # [100%]
[root@QuDaoMysql _ rpminstall] # rpm-ivh mysql-community-client-5.7.16-1.el6.x86_64.rpm
Warning: mysql-community-client-5.7.16-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... # [100%]
1:mysql-community-client # # [100%]
[root@QuDaoMysql _ rpminstall] # rpm-ivh mysql-community-server-5.7.16-1.el6.x86_64.rpm
Warning: mysql-community-server-5.7.16-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... # [100%]
1:mysql-community-server warning: / etc/my.cnf created as / etc/my.cnf.rpmnew
# [100%]
[root@QuDaoMysql _ rpminstall] #
My.cnf will be generated during installation to manually overwrite the original
[root@QuDaoMysql _ rpminstall] # cp / etc/my.cnf.rpmnew / etc/my.cnf
Cp: overwrite `/ etc/my.cnf'? Y
[root@QuDaoMysql _ rpminstall] #
4. Start mysql
[root@QuDaoMysql _ rpminstall] # / etc/rc.d/init.d/mysqld start
Initializing MySQL database: [OK]
Installing validate password plugin: [OK]
Starting mysqld: [OK]
[root@QuDaoMysql _ rpminstall] #
5. Mysql5.7 begins to have a default password
[root@QuDaoMysql _ rpminstall] # cat / var/log/mysqld.log | grep 'temporary password'
2016-10-20T03:07:36.130787Z 1 [Note] A temporary password is generated for root@localhost: EGlLlD,dg2qe
[root@QuDaoMysql _ rpminstall] #
The initial password is EGlLlD,dg2qe
6. Log in
Enter the password, reset the password
[root@QuDaoMysql _ rpminstall] # mysql-uroot-p
Enter password:
Welcome to the MySQL monitor. Commands end with; or\ g.
Your MySQL connection id is 3
Server version: 5.7.16
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
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 >
Mysql > SET PASSWORD = PASSWORD ('xxxxxx')
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
Mysql >
Mysql > SET PASSWORD = PASSWORD ('xxxxxxx')
Query OK, 0 rows affected, 1 warning (0.00 sec)
Mysql >
7. Authorize remote connection
Mysql > GRANT ALL PRIVILEGES ON *. * TO 'root'@'%' IDENTIFIED BY' xxxxx' WITH GRANT OPTION
Query OK, 0 rows affected, 1 warning (0.00 sec)
Mysql > FLUSH PRIVILEGES
Query OK, 0 rows affected (0.00 sec)
Mysql >
Mysql >
Description: if the remote connection is not available, turn off the firewall.
8. Configure mysql to start automatically
# chkconfig-- level 345mysqld on-- set MySQL to start automatically at level 345
9. Modify the default directory
Shut down the database
[root@QuDaoMysql prlife] # service mysqld stop
Stopping mysqld: [OK]
[root@QuDaoMysql prlife] # cd / var/lib/
Copy must use-a, otherwise permissions will be messed up
[root@QuDaoMysql lib] # cp-a mysql / prlife/
Modify the first file
Modify / etc/my.cnf, backup is required before modification
# datadir=/var/lib/mysql
# socket=/var/lib/mysql/mysql.sock
Datadir=/prlife/mysql/data
Socket=/prlife/mysql/data/mysql.sock
Add the following parameters, otherwise an error will be reported.
[mysql.server]
User=mysql
Basedir=/prlife/mysql/data/mysql
[client]
Socket=/prlife/mysql/data/mysql.sock
Modify the second file: mysqld
Back up before modification
[root@QuDaoMysql mysql] # cp / etc/init.d/mysqld / etc/init.d/mysqld_bak
[root@QuDaoMysql mysql] # vi / etc/init.d/mysqld
Replace all / var/lib/mysql with / prlife/mysql/data
Modify the third file
Back up before modification
Cp / usr/bin/mysqld_safe / usr/bin/mysqld_safebak
Vi / usr/bin/mysqld_safe
Replace all / var/lib/mysql with / prlife/mysql/data
(4) create a link to mysql.sock
[root@QuDaoMysql lib] # mkdir-p / var/lib/mysql/
[root@QuDaoMysql lib] # chown-R mysql.mysql / var/lib/mysql
[root@QuDaoMysql lib] # ln-s / prlife/mysql/data/mysql.sock / var/lib/mysql/mysql.sock
Restart the database
Thank you for reading this article carefully. I hope the article "how to install mysql5.7.16 Database in Linux 6.3" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!