CentOS7 default database is mariadb, but a lot of the use of MySQL, but the CentOS7 yum source default seems to be no MySQL.
The previous installation was 5.6 but I would like to install 5.7 Yum install is the simplest to try to compile and install various problems, and finally decided to use Yum.
1. Uninstall first stop the MySQL process has not been installed can skip directly
Pkill-9 mysqld
Rpm-qa|grep-i MySQL
Yum-y Remove with command
Yum-y Remove mysql-community-client-5.6.38-2.el7.x86_64
Uninstall the Rpm-ev with no drop
Unload until No
2. Download MySQL repo source This installation mysql5.7.20/** correct it, this source is the latest version of the download ****/
[Email protected] ~]# cd/usr/local/src/
[Email protected] src]# wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm
[Email protected] src]# RPM-IVH mysql57-community-release-el7-8.noarch.rpm
[Email protected] src]# yum-y install Mysql-server
(You can also specify the installation directory Yum--installroot=/usr/local/mysql--releasever=/-y install mysql-server) I did not try to install the environment variable configuration is not your tube, installed on the direct start on the line. The installation path is the default.
All the way Y
Follow the steps to install it,
Default configuration file path:
Configuration file:/etc/my.cnf
Log file:/var/log/var/log/mysqld.log
Service startup script:/usr/lib/systemd/system/mysqld.service
Socket file:/var/run/mysqld/mysqld.pid
Configuring MY.CNF VIM/ETC/MY.CNF
- [Mysqld]
- #
- # Remove Leading # and set to the amount of RAM for the most Important data
- # Cache in MySQL. Start at 70% of all RAM for dedicated server, else 10%.
- # innodb_buffer_pool_size = 128M
- #
- # Remove Leading # to turn on a very important data integrity option: logging
- # changes to the binary log between backups.
- # Log_bin
- #
- # Remove Leading # to set options mainly useful for reporting servers.
- # The server defaults is faster for transactions and fast selects.
- # Adjust sizes as needed, experiment to find the optimal values.
- # join_buffer_size = 128M
- # sort_buffer_size = 2M
- # read_rnd_buffer_size = 2M
- datadir=/Var/lib/mysql
- socket=/Var/lib/mysql/mysql.sock
- server_id = 1
- Expire_logs_days = 3
- # Disabling Symbolic-links is recommended to Prevent assorted security risks
- symbolic-links=0
- log-error=/var/log/mysqld.log
- pid-file=/var/run/mysqld/mysqld.pid
However, after the installation is complete, the password is a random password and requires a password reset.
4. Start the MySQL service
Service mysqld Restart
Reset Password
[[email protected] ~]# grep "Password"/var/log/mysqld.log
You can see the input mysql-u root-p password into the first login, you need to reset the password or nothing can be manipulated
Next Reset Password: 5.7.20 for security password must contain alphanumeric characters
Stepped on the hole, Ah, set up several times. And this IP can not be% do not know why the first time set to% did not successfully boarded to change can be changed.
A simple way to change the password http://blog.csdn.net/z13615480737/article/details/78907697
Alter user ' root ' @ ' localhost ' identified by ' root!! 2018 ';
Finally, remember to refresh the permissions;
Flush Privileges
You can also add new users directly
CREATE USER ' root ' @ '% ' identified by ' your password ';
Grant all on * * to ' root001 ' @ ' percent ' identified by ' [E-mail protected]@ ' with GRANT option;
Add root user specified can be arbitrary IP login, if you want to limit only allow the specified IP login please replace% to IP address
Problem: If you find a password not found!!!!!
FIX: You can only change your password by forgetting your password!!! The password was not found during the installation process??? Toss a good long time by changing the password back to find, the original installed before the database in, there is no production of new database!! The previous configuration is used.
2. See if MySQL is up yet? Did you initialize the database? General directly start the database can use grep "password"/var/log/mysqld.log see random password
To modify the login settings for MySQL: #vi/etc/my.cnf in the paragraph in [mysqld]: Skip-grant-tables Save and Exit VI. Restart Mysqld
Restart Mysqld
#/etc/init.d/mysqld Restart (Service mysqld restart)
Use MySQL
Update user set Password=password ("12345") where user= "root";
MySQL 5.7 database does not have a password field with the Authentication_string field
mysql> Update Mysql.user Set Authentication_string=password (' root ') where user= ' root ';
Flush privileges;
Change the password after changing it back
Installing MySQL5.7.20 with Yum under CentOS 7.4 is the simplest