Centos 7 no longer pre-installs mysql
I uninstalled the original mariadb (because I... failed to download mysql directly when adding mysql yum source)
yum -y remove mariadb
Go to the official website to download the yum rpm package of mysql
# mysql80-community-release-el7-2.noarch.rpm#You can use this to download wget directly'http://repo.mysql.com/mysql80-community-release-el7-2.noarch.rpm'
https://dev.mysql.com/downloads/file/?id=482300
download
# mysql-community-server-8.0.15-1.e17.x86_64.rpm
Download the rpm package after it cannot be downloaded normally
https://dev.mysql.com/downloads/file/?id=484547
use
rpm -ivh mysql80-community-release-el7-2.noarch.rpm install mysql yum source
Then you can use
yum install mysql-community-server download and install
( If your network is fast, it can be done all at once, of course, configured, yum mirror source)
Of course you can go to the official website to download the rpm package
Installed!
Start mysql service
service mysqld start
Check service status
systemctl status mysqld
shut down
service mysqld stop
Reboot
service mysqld restart
Can modify the configuration
vim /etc/my.cnf
If this error occurs,
reference
https://www.linuxidc.com/Linux/2010-06/26890.htm
rm -rf /var/lib/mysql/*
rm /var/lock/subsys/mysqld
killall mysqld
service mysqld start
Set mysql to boot up
systemctl enable mysqld
systemctl daemon-reload
change Password
grep"A temporary password is generated for root@localhost" /var/log/mysqld.log
My password here is the string after the colon in red font, you can select them to copy
Then type
mysql -uroot -p
Press Enter and then paste the password
Change the root password:
ALTERUSER'root'@'localhost' IDENTIFIED BY 'Your password';
Create a new user:
CREATEUSER'You create a username'@'%' IDENTIFIED BY 'password';
Give this new user remote login permissions:
GRANTALLON*.*TO'Username just created'@'%';
Take a look at user
use mysql;selectuser,host,plugin fromuser;
The host column is the specified login ip, for example, user=root host=192.168.1.1. This means that the root user can only access through the 192.168.1.1 client, and% is a wildcard, if host=192.168.1.1 1.%, then it means that as long as the client whose ip is host=192.168.1. prefix can connect, then host=% means that all ips have the right to connect, which is why when the remote connection is turned on , Most people directly change the host to% because it saves trouble
The encoding defaults to utf8mb4, no need to change
The client does not support the encryption method of caching_sha2_password
Change the password encryption method to mysql_native_password
View password verification restrictions
SHOW VARIABLES LIKE'validate_password%';
Set the strength of the verification password, the default is medium,
0 /LOW: Only verify the length;
1 /MEDIUM: verify length, numbers, capitalization, and special characters;
2 /STRONG: Verify length, numbers, capitalization, special characters, dictionary files;
setglobal validate_password.policy=LOW;
Otherwise it's annoying to appear all day long. .
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
Modify encryption policy
ALTERUSER'Your username'@'%' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;
ALTER USER 'username'@'%' IDENTIFIED WITH mysql_native_password BY 'password';
FLUSH PRIVILEGES;
Remote connection is ok
Recommended Posts