Centos install mysql 5.7
Step 1: Download the appropriate mysql RPM package for your server
Download address: downloads.mysql.com/archives/co…
Choose the right package to download
Download the command
wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
Copy the code
Download and execute
sudo rpm -Uvh mysql57-community-release-el7-11.noarch.rpm
Copy the code
Step 2: Install mysql
Execute the command
sudo yum install mysql-community-server
Copy the code
The installation process will prompt information, all enter Y agree, until the installation is complete.
During the installation, the root user and the random password are automatically created. The random password is stored in the /var/log/mysqld.log file
grep 'temporary password' /var/log/mysqld.log
Copy the code
Step 3: Start mysql
Start the mysql
sudo service mysqld start
Copy the code
Viewing the Health status
sudo service mysqld status
Copy the code
Use the random password you just found to log in to the root user. After login, you must change the random password, otherwise you are not allowed to operate
SET PASSWORD = PASSWORD('new password');
Copy the code
Note: The new password must be a mixture of case and symbols or it will not pass
Use the new password to log in again
mysql -u root -p
Copy the code
Modify remote user authentication after login
ALTER USER 'root' @ 'localhost' IDENTIFIED BY 'new password';Copy the code
Step 4: Change the database format
Generally, mysql is installed by default, and the created database does not support Chinese by default, so Chinese cannot be inserted or garbled characters will appear, so we first modify the database Settings after installing the database to make it support Chinese.
By editing the database configuration /etc/my.cnf
Add [client] default-character-set=utf8 before [mysqld] add [client] default-character-set=utf8 after [mysqld] add [client] default-character-set=utf8 after [mysqld] add [client] default-character-set=utf8
After saving the configuration file, restart the mysql database
sudo systemctl restart mysqld.service
Copy the code
At this point, the data created is in Chinese.