Compile and install mysql5.7 in CentOS
Download
I can't find how to download mysql from the official website. Therefore, I uploaded the file to Baidu cloud for free download (originally I wanted to upload the file to CSDN, but I only had 75 MB of permission and I was not authorized enough !).
Install
The first step is to upload the two installation files to centOS. Do you still need to worry about how to upload them? I will tell you if you need it.
Step 2, "haomu will not go back !", Check whether there are other versions of mysql on centOS. If yes, clean it up!Note: If you have mysql configuration and data on it, make sure to back up the data. Please refer to upgrade mysql to 5.7
[root@iZ23gsv94suZ soft]# yum remove mysql*Loaded plugins: securitySetting up Remove ProcessResolving Dependencies--> Running transaction check---> Package mysql-libs.x86_64 0:5.1.73-3.el6_5 will be erased...Is this ok [y/N]: yRemoved: mysql-libs.x86_64 0:5.1.73-3.el6_5 Dependency Removed: cronie.x86_64 0:1.4.4-12.el6 cronie-anacron.x86_64 0:1.4.4-12.el6 crontabs.noarch 0:1.10-33.el6 postfix.x86_64 2:2.6.6-6.el6_5 redhat-lsb-core.x86_64 0:4.0-7.el6.centos sysstat.x86_64 0:9.0.4-22.el6 Complete!
Why uninstall it ?! If you want to ask me more, I don't think I want to answer you!
However, to keep my friendly attitude, I still want to tell you that if you do not uninstall these hateful old versions, you will be blocked during the installation process! Will make you unable to install it! Of course, if you don't believe it, you can try it! ::>_<:: (●-●)
Command is yum remove mysql *
Step 3: Check whether it is uninstalled.
[root@iZ23gsv94suZ soft]# rpm -qa | grep -i mysql*
Please allow me to leave an aside. The office is a bit cold and lonely! Okay, I have turned on the air conditioner, so I will continue to come back. Let's take a look at the next step.
Step 4: Install mysql
[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.comSupport MySQL by buying support/licenses at http://shop.mysql.com
1. Note that '/root/. mysql_secret' tells you that the initialization password is in this file, so wait for a while to find the password. 2. Of course, there is no other statement but 'set password' will be accepted, which will be used later.
To be honest, I also discovered these two points for the first time. It's really hard-earned!
So let's start looking at the next step ?! Oh, wait. What do you think of next step? A glance at the "Beautiful programmer sister" around me "?
Oh, you think too much. I mean, your next step is
[root@iZ23gsv94suZ mysql]# mysql
If you answer me Yes, then the error will occur:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
Well, don't sell off the customs. If you ask me not to sell off the customs, I will be serious. Solemnly speaking, let's proceed! Oh, I forgot the first step. Let's count it. When there are too many selling customs, you will have to forget it!
Step 5: Start the mysql service.
[root@iZ23gsv94suZ mysql]# service mysql startStarting MySQL. SUCCESS!
Okay, do you think "My pants are all taken off, you tell me this !", Oh, that's right. I just made the 28000 mistake and found another half a day.
Step 6: connect to mysql
[root@iZ23gsv94suZ mysql]# mysql -uroot -pEnter password: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
What, I don't even know the password ?!!!!!
So please[root@iZ23gsv94suZ mysql]# vim /root/.mysql_secretYes, you will find the answer in this file. The password is here. Haha, don't forget, I told you before!
So what do you decide when you find the password to connect? I still want to sell off the customs, Oh, think about it or forget it. Hurry up and go home! You will certainly say that step 7 is not to change the password, so:
mysql> use mysqlERROR 1820 (HY000): You must SET PASSWORD before executing this statement
What's wrong with this mistake? Don't forget, I reminded you before. Next step:
Step 7: set password
mysql> set password=password("root");Query OK, 0 rows affected (0.00 sec)
Okay. Now, change the password!
Step 8: change the password
mysql> use mysqlReading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedmysql> update user set password=PASSWORD("lixiaoli") where user="root";Query OK, 1 row affected (0.00 sec)Rows matched: 1 Changed: 1 Warnings: 0mysql> flush privileges;Query OK, 0 rows affected (0.00 sec)
Haha, please do not believe that my password is "lixiaoli ".
So, if you see this, I think I still write well, you may feel that there is no step 9, and so on, many projects are, we need to have access to the mysql database on other computers, so you did it!
What is it? Why can't it be connected?
You think about it. If you can access it at will, what else do you want to say next?
Step 9: enable remote access
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)
What does it mean? I want to tell you, but I know a little bit. Okay, I'll do my best!
- Grant all privileges: all permissions are enabled, including addition, deletion, modification, and query!
- .: When there is a database data table.
- Root: user Name!
- '192. 168.44.11 'is naturally about enabling remote permissions for that machine.
- 'Lixiaoli': the password.
Then, test it again!
Succeeded. succeeded! I think it's almost time to go home!
Step 10: I didn't have this step in database creation. Later, my friend asked me, do I not need to set the encoding format? My answer is: "I don't know !", Don't know? Because I think the encoding method can be set on the database!
Then, a table containing Chinese characters is created without garbled characters.