MySQL8.0.26-Linux version installation
1. Prepare a Linux server
Cloud servers or virtual machines are both available;
The version of Linux is CentOS7;
2. Download the MySQL installation package for Linux
https://downloads.mysql.com/archives/community/
3. Create a directory and upload the MySQL installation package
/usr/local/src/MySql/
4. Unzip
# 进入到此目录
cd /usr/local/src/MySql/
# 解压到指定目录,不指定默认解压到当前目录,因为现在进入到了MySql所以写不写-C 目录路径
tar -xvf mysql-8.0.26-1.el7.x86_64.rpm-bundle.tar -C 目录路径
5. Install the mysql installation package
cd MySqL
# 按照以下顺序进行安装
rpm -ivh mysql-community-common-8.0.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-plugins-8.0.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.26-1.el7.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-libs-compat-8.0.26-1.el7.x86_64.rpm --nodeps --force
yum install openssl-devel
rpm -ivh mysql-community-devel-8.0.26-1.el7.x86_64.rpm
# 安装客户端
rpm -ivh mysql-community-client-8.0.26-1.el7.x86_64.rpm
#安装服务端
rpm -ivh mysql-community-server-8.0.26-1.el7.x86_64.rpm --nodeps --force
6. Start the MySQL service
- In Linux, MySql will automatically register a system service after it is installed, and the service name is mysqld.
#启动
systemctl start mysqld
#重启
systemctl restart mysqld
#停止
systemctl stop mysqld
7. Query the automatically generated root user password
grep 'temporary password' /var/log/mysqld.log
Command line execution instructions:
mysql -u root -p
Then enter the automatically generated password queried above to complete the login.
HGOWEhvX>1VY
8. Change root user password
After logging in to MySQL, you need to change the automatically generated password that is difficult to remember into a familiar password that is easy to remember.
ALTER USER 'root'@'localhost' IDENTIFIED BY '1234';
An error will be reported when executing the above SQL. The reason is that the password set is too simple and the password complexity is not enough. We can set the password complexity to simple type and the password length to 4.
set global validate_password.policy = 0;
set global validate_password.length = 4;
After lowering the password verification rules, execute the above command to change the password again.
9. Create user
The default root user can only access the current node localhost and cannot be accessed remotely. We also need to create a root account for remote access.
create user 'root'@'%' IDENTIFIED WITH mysql_native_password BY '1234';
10. And assign permissions to the root user
grant all on *.* to 'root'@'%';
11. Reconnect to MySQL
exit
mysql -u root -p
Then enter the password: 1234
12. Remotely connect to MySQL through SqlYog
-
Use SqlYog in Windows to connect to MySql installed in Linux system
-
The premise is that the firewall is turned off in Linux
MySQL Uninstall-Linux version
Stop MySQL service
systemctl stop mysqld
Query MySQL installation files
rpm -qa | grep -i mysql
Uninstall all MySQL installation packages queried above
rpm -e mysql-community-client-plugins-8.0.26-1.el7.x86_64 --nodeps
rpm -e mysql-community-server-8.0.26-1.el7.x86_64 --nodeps
rpm -e mysql-community-common-8.0.26-1.el7.x86_64 --nodeps
rpm -e mysql-community-libs-8.0.26-1.el7.x86_64 --nodeps
rpm -e mysql-community-client-8.0.26-1.el7.x86_64 --nodeps
rpm -e mysql-community-libs-compat-8.0.26-1.el7.x86_64 --nodeps
Delete the MySQL data storage directory
rm -rf /var/lib/mysql/
Delete MySQL configuration file backup
rm -rf /etc/my.cnf.rpmsave