First, confirm that Ali Cloud's server mirror is a public mirror version of the CoentOs 7 series (previously built for upload by others, not a pure environment, otherwise it is prone to problems)
Turn over to the last step before installing.
I. Start Installation
1. Download the package of mysql. I downloaded the following version
2. Upload to directory/usr/local/
3. Unzip command:
tar -zxvf mysql-5.7.32-linux-glibc2.12-x86_64.tar.gz
4. Change the name of the unzipped directory
mv mysql-5.7.32-linux-glibc2.12-x86_64.tar.gz mysql-5.7.32
5. Create users and user groups for mysql (I don't know why to create such a regular user, and I see others do the same, so follow along)
groupadd mysql #Create mysql user group
useradd -r -g mysql mysql #Create mysql user under mysql user group
6. Change permissions and create folders
mkdir /usr/local/mysql-5.7.32/data #The data folder is used to store data such as database tables
mkdir /data/mysql #This file has some log files or something under it
chown -R mysql.mysql /usr/local/mysql-5.7.32 #Give MySQL users permissions to the mysql-5.7.32 folder and its subfolders and files
chown -R mysql.mysql /data/mysql #Give mysql users permissions to both the mysql folder and its subfolders and files
7. Modify the configuration file (Note: This file was generated without knowing which step. To avoid changes, I backed up the file first, recreated a new my.cnf file, and changed it in the new file)
mv /etc/my,cnf /etc/my.cnf_bak #Rename original file
touch my.cnf #create a new file
vi /etc/my.cnf #vi mode
The following
[mysqld]
# data file path
datadir=/usr/local/mysql-5.7.32/data
basedir=/usr/local/mysql-5.7.32
port=3306
user=mysql
character-set-server=utf8
explicit_defaults_for_timestamp=true
[mysqld_safe]
# log file path
log-error=/data/mysql/mysqld.log
pid-file=/data/mysql/mysqld.pid
8. Install dependent packages and initialize
yum install libaio #Install dependent packages, I tried not to install, and then reported a mistake...
8.1 Initialization
./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql-5.7.32/ --datadir=/usr/local/mysql-5.7.32/data/ --user=mysql --initialize
8.2 Remember to give a default password when initialization is successful. Be sure to remember that otherwise you will not be able to log in later
9. Add mysql to system services
cp /usr/local/mysql-5.7.32/support-files/mysql.server /etc/init.d/mysql
10. Set up startup
chkconfig mysql on
11. Add mysql to the environment variable and start mysql in a different directory later
vi /etc/profile
export PATH=$PATH:/usr/local/mysql-5.7.32/bin #Put this line in profile File
source /etc/profile #Make the file effective immediately
12. Start mysql
service mysql start
13. Log in to mysql
mysql -u root -p
14. Enter the default password you just given. It's hidden here. You just enter it, but it won't show you anyway. When you finish typing, return. If you succeed, it will look like the following
15. Modify your password (provided you start mysql and are logged in, enter the following instructions under mysql > as shown above)
SET PASSWORD = PASSWORD('123456');
ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
FLUSH PRIVILEGES;
16. Remote login, if not set, external access will not be connected
Enter the following command in the logon state
use mysql #Access mysql Library update user set host = '%' where user = 'root'; #Enable root access to any more host s FLUSH PRIVILEGES;
2. Summary of problem trampling pit
1. I wrote it with reference to other articles. Their directory structure is different from mine, which makes some commands different when I initialize. Sometimes I bring an extra slash which causes the initialization to fail.
2. There is also a directory permission issue. I created a large directory with root first, changed the permissions, created some small directories, and then forgot to give mysql permissions.
Causes startup to fail because it writes but does not have permission
3. The biggest problem I encountered was that I had installed jdk and redis for the first time and made various errors when installing mysql. I tried tar,gz and yum.
Finally, everything went wrong. Not only did mysql not be installed, but my server ll command checked the files and prompted that there was no such command. After consulting Ali Yun's customer service, the customer service was patient and told me that maybe my image was not pure.
There were no configuration files left when mysql was installed, so I started by checking to see if the environment was pure, and finally I rebuilt it and the services were reinstalled.
4. Last but not least, if you are not familiar with Aliyun, you should be aware that if you have deployed your own services, they are all normal and can not be accessed from outside.
The first thing you need to do is check if your firewall has any open ports. I will simply close the firewall because I am learning by myself and it is not a big problem.
Second, to Aliyun's official network, add the corresponding ports to the security group in your own server instance so that the outside can access them.
For the first time, I didn't know about it. It took me a long time to know about it. I added security groups incorrectly. Originally from Shanghai, I ended up in London.
So there was a problem. Look slowly, if you can't, consult Ali Yun's customer service. The server is generally not a big problem, but we have set it up incorrectly.
5. There are some pits that I haven't written, because I have no problems, such as I didn't add the configuration at that time, and then I made a mistake. After that I added them, there are no errors.
There are also configurations like boot-up, some people do not have permission to execute, this I did not appear, follow the steps, the problem should be minor.