This article is from the blog of Silent Wang Er, reprinting must indicate the source.Technical Exchange Group 120926808

Linux install MySQL.

1. Installation Files

mysql website I can't find how to download it.So, I upload to Baidu cloud for everyone Free Download.

2. Installation

1. Upload Files

Use linux The sz and rz commands of can be uploaded, or can be uploaded using the filezila tool. After uploading, see the following file:

(2) Clean up mysql

This step is critical to ensure installation mysql Previously, mysql was clean on Linux, which often resulted in installation failures.(
Upgrade mysql to 5.7 , which is described in detail in this article.

3. Install MySQL-server

[root@iZ23gsv94suZ soft]# rpm -ivh MySQL-server-5.7.4_m14-1.el6.x86_64.rpm 
Preparing...                ########################################### [100%]
find: `/var/lib/mysql': No such file or directory
   1:MySQL-server           ########################################### [100%]

A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
You will find that password in '/root/.mysql_secret'.

You must change that password on your first connect,
no other statement but 'SET PASSWORD' will be accepted.
See the manual for the semantics of the 'password expired' flag.


Please report any problems at http://bugs.mysql.com/

The latest information about MySQL is available on the web at

  http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20

tips:

  1. Note the file'/root/.mysql_secret'.
  2. Note that no other statement but'SET PASSWORD'will be accepted.

(4) Install MySQL-client

rpm -ivh MySQL-client-5.7.4_m14-1.el6.x86_64.rpm

5. Start mysql service

[root@iZ23gsv94suZ mysql]# service mysql start
Starting MySQL. SUCCESS! 
  • 1
  • 2
  • 1
  • 2

_, Connect mysql

[root@iZ23gsv94suZ mysql]# mysql -uroot -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
  • 1
  • 2
  • 3
  • 1
  • 2
  • 3

The password is in the file'/root/.mysql_secret'.

_, Change the default password

mysql> use mysql
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
  • 1
  • 2
  • 1
  • 2

An error has occurred at this point and we need to:

mysql> set password=password("root");
Query OK, 0 rows affected (0.00 sec)
  • 1
  • 2
  • 1
  • 2

_, Change password

mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update user set password=PASSWORD("lixiaoli") where user="root";
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

Ha-ha, please don't believe my password is "lixiaoli". I just like her!Yes, it is Li Xiaoli.

_, turn on the firewall

To keep Linux secure, we need to turn on the firewall and at the same time release port 3306 of mysql.(
Be careful to turn off the firewall first

service iptables stop
  • 1
  • 1
vim /etc/sysconfig/iptables
  • 1
  • 1

Open the above file and add the following:

-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
  • 1
  • 1
service iptables save   
service iptables start  
  • 1
  • 2
  • 1
  • 2

_, Open remote access rights

mysql> grant all privileges on *.* to root@'192.168.44.11' identified by "lixiaoli";
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  1. "grant all privileges": Turn on all permissions, including add, delete and change checks!
  2. ".": When there are datasheets in the database.
  3. "root": user name!
  4. "'192.168.44.11'" naturally turns on remote permissions for that machine.
  5. ''lixiaoli': naturally the corresponding password

Keywords: MySQL Linux RPM iptables

Added by ReDucTor on Thu, 06 Jun 2019 19:49:59 +0300