Tag: No global MYSQL8 statement authentication is written to access reload driver
CentOS 7 comes with MARIADB (developed by a former MySQL development engineer, so with, MySQL has a lot in common)
1, check the unloaded mariadb
Rpm-qa|grep mariadb//query out installed MARIADB
rpm -e
--nodeps 文件名 //卸载mariadb,文件名为上述命令查询出来的文件
2. See if MySQL is already installed
Rpm-qa | Grep-i MySQL
Find MySQL files, delete using rm-rf mysql file path
find / -
name
mysql
Delete a distributed MySQL file
find / -
name
mysql / # whereis mysql
Delete a configuration document
Rm-rf/etc/my.cnf
Find out if the machine installs MySQL again
Rpm-qa|grep-i MySQL
View MySQL resources provided by the Yum Library
Yum List mysql*
3. Install MySQL Dependency package
yum -y install openssl-devel
yum install perl-JSON
Installation of MySQL necessary dependent libnuma.so.1 relies on the need to install Libnuma
It is recommended to use the Yum method to avoid lack of reliance
Install Libnuma in yum mode
Yum Install Numactl-y
Yum Install Libaio-y
Yum Install Perl-y
Yum-y Install Libaio-devel
yum -y install libaio.so.1 libgcc_s.so.1 libstdc++.so.6
yum
update
libstdc++-4.4.7-4.el6.x86_64
yum search libaio # 检索相关信息
yum install libaio # 安装依赖包
yum install net-tools
4, to the MySQL official website download Universal package, can also download the original code compilation, this diagram simply download the compiled generic package directly
Download with wget
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz #解压后是编译完的包
or wget Https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.11-linux-glibc2.12-x86_64.tar #解压后是rpm包
Unzip the downloaded compressed package into the MySQL directory under/usr/local/(MySQL directory manually created, mkdir MySQL)
tar -zxvf mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz -C /usr/
local
/mysql
or unzip it before moving to the specified directory
TAR-ZXVF mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz #解压
Mv/root/mysql-8.0.11-linux-glibc2.12-i686/usr/local/mysql #移动并重命名文件
5, after the TAR package decompression (RPM installation method), install MySQL under/usr/local/mysql, pay attention to the installation has successively , has the dependency
rpm -ivh …common.rpm
rpm -ivh …libs.rpm
rpm -ivh …client.rpm
rpm -ivh …server.rpm
The following directory will be generated after installation to store MySQL-related files clip_image002... rpm installation reference: Https://www.jb51.net/article/138787.htm6, tar.gz decompression of the compilation package installationReference: 80144890#commentboxhttps://www.linuxidc.com/Linux/2018-04/152039.htm6.1. Create a new folder in MySQL root directory data for storing
mkdir data
6.2, create the root user group and root user, the general system already exists root group and root user, can choose to create other users and groups
Groupadd Root
Useradd-g root root
6.3. Configuring the My.cnf File
Create the MY.CNF profile in the/etc/directory
Touch my.cnf
Other parameters are configured according to the situation;
MY.CNF Optimization Reference: https://www.cnblogs.com/langdashu/p/5889352.html
Https://www.cnblogs.com/mydriverc/p/8297144.html
Https://www.cnblogs.com/panwenbin-logs/p/8360703.html
Directories and log files that do not exist need to be created before they can be reported as permission errors that cannot be created
6.4. Change MySQL directory permissions
Chown-r root:root/usr/local/mysql/
Only the owning user has permissions
chmod 755/usr/local/mysql-r
All users have options
chmod 777/usr/local/mysql-r
Or
Chown-r MySQL.
Chgrp-r MySQL.
Note that there is one last thing
7. Initialize the database
Under the MySQL directory
./bin/mysqld
--initialize --user=root --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
./bin/mysql_ssl_rsa_setup
The generated temporary password is itulu+,gz5;3
8. Build MySQL Service
Add to System service
Cp-a./support-files/mysql.server/etc/init.d/mysqld
Or
Cp-v./support-files/mysql.server/etc/init.d/
Add Execute permission (optional)
chmod +x/etc/rc.d/init.d/mysqld
Adds the specified system service, allows the chkconfig instruction to manage it, and adds relevant data to the system-initiated narrative file.
Chkconfig--add mysqld
Check if the service is in effect
Chkconfig--list mysqld
or chkconfig--list View all services
9. Configuring Global Environment variables
Edit/Etc/profile File
Vim/etc/profile
Add the following two lines of configuration at the bottom of the profile file and exit after saving
Path=/usr/local/mysql/bin:/usr/local/mysql/lib: $PATH
Export PATH
Note: PATH This must be configured according to their own installation location , I did not pay attention to the direct reference to other people to fill out a wrong address "/data/mysql/bin:/data/mysql/lib: $PATH", After the error has been
Setting environment variables takes effect immediately
Source/etc/profile
10. Start the MySQL service
./mysqld--defaults-file=/etc/my.cnf--user=root & (Optional execution)
Systemctl start Mysql.service (standard start service mode)
Or
(Shutdown method for service Mysql.server stop
Service Mysql.server {start|stop|restart|reload|force-reload|status})
Check whether the service is started
Inux above: Service MySQL status to see if it starts, or Netstat-tlunp|grep 3306
Above windows: Enter "Netstat-an|find" 3306 "in the" cmd "command line, if there is a description open.
Where the Mysql.server.service service is green, indicating success, if it is not necessary to check the system error log and service logs to troubleshoot
11. Log in to MySQL
11.1, execute the command, log in MySQL
Mysql-u root-p
Enter the password you previously initialized
11.2 After you enter MySQL, you must reset the initial password to perform other operations
Update password
ALTER
USER
‘root‘
@
‘localhost‘
IDENTIFIED
BY
‘新密码‘
; #以默认密码认证插件来验证密码
ALTER
USER
‘root‘
@
‘localhost‘
IDENTIFIED
WITH
mysql_native_password
BY
‘新密码‘
; #以指定的密码验证方式来验证密码
In configuration file my.cnfdefault_authentication_plugin 默认密码认证方式,因为当前有很多数据库工具和链接包都不支持“caching_sha2_password”,
这为了方便改为之前的认证方式
Default_authentication_plugin=mysql_native_password
Before MySQL 8.04 can be performed by:
SET
PASSWORD
=
PASSWORD
(
‘[修改的密码]‘
); 来修改密码。
But MySQL8.0.4 start, this is not possible. Because before, MySQL's password authentication plugin is "Mysql_native_password", after MySQL 8.04 uses "Caching_sha2_password".
11.3. View MySQL basic information
MySQL Clear screen command system clear;
11.4. Create a user that allows remote administration
The host of administrator root is localhost, which represents only localhost login access. If you want to allow other IP logins to be opened, you need to add a new host. If you want to allow remote IP access, you can modify it directly to "%", but this will cause the local to not connect.
Therefore, it is best to create new administrative users that allow remote connections.
To create a user:
CREATE USER ' ZW ' @ '% ' identified with Mysql_native_password by ' password ';
# (need to note: mysql8.04 after the encryption method modified)
#检查用户
Select User, host, plugin, authentication_string from user\g;
#查询语句 \g end indicates formatted output
granting permissions
#授权所有权限
GRANT all privileges on * * to ' ZW ' @ '% ';
#授权基本的查询修改权限, set on demand
GRANT select,insert,update,delete,create,drop,alter on *. * to ' baseroot ' @ '% ';
grant all privileges on *.* to ‘用户‘@‘%‘ identified by ‘密码‘ with grant option;
- All privileges: Indicates that all permissions are granted to the user. You can also specify specific permissions, such as: SELECT, CREATE, drop, and so on.
- On: Indicates which databases and tables are in effect for these permissions, in the format: Database name. Table name, where "*. *" is written to represent all databases, all tables. If I want to specify that permissions should be applied to the user table of the test library, you can write this: Test.user
- To: Which user to grant permissions to. Format: "User name" @ "Login IP or domain name". % means no limit and can be logged in on any host. For example: "ZW" @ "192.168.0.%", indicating ZW this user can only be logged in the 192.168.0IP segment
- Identified by: Specify the user's login password
- With GRANT OPTION: Allows users to authorize their own permissions to other users
You can use grant to add permissions to the user, the permissions will automatically overlay, not overwrite the permissions previously granted, such as when you first add a SELECT permission to the user, and then add an INSERT permission to the user, then the user has both select and insert permissions.
For a list of user details, please refer to the MySQL website description: http://dev.mysql.com/doc/refman/5.7/en/privileges-provided.html
#刷新权限:
After you have made permission changes to the user, you must remember to reload the permissions and write the permissions information from memory to the database.
mysql> flush Privileges;
View User Permissions
Show grants for ' ZW ' @ '% ';
12. Firewall operation
Add Port 3306 to the firewall
#检查端口占用情况
NETSTAT-LNP | grep 3306
#查看是否开启防火墙
Systemctl Status Firewalld.serivce
#开启防火墙
Systemctl Start Firewalld.serivce
#查看防火墙已开放的端口号
Firewall-cmd--list-ports
#添加端口进防火墙
Firewall-cmd--permanent--zone=public--add-port=3306/tcp
#重新加载防火墙
Firewall-cmd--reload
#重启防火墙服务 (optional)
Systemctl Restart Firewalld.service
Firewall-cmd--zone=public--add-port=80/tcp--permanent
The firewall in the CENTOS7 is changed to firewall, and using iptables is not working, the method of opening the port is as follows:
Firewall-cmd--zone=public--add-port=80/tcp--permanent
Return success for Success
Command meaning:
--zone #作用域
--add-port=80/tcp #添加端口 in the format: Port/Communication protocol
--permanent #永久生效
To restart the firewall:
Systemctl Restart Firewalld.service
To turn off the firewall:
Systemctl Stop Firewalld.service
viewing ports for listening (Listen)
Netstat-lntp
Check which process the port is using
Netstat-lnp|grep 8080
To view the ports that have been developed
Firewall-cmd--list-ports
Gets the details of the process it occupies based on the port number
Netstat-tlnp|grep 80
TCP 0 0 192.168.33.10:80 0.0.0.0:* LISTEN 5014/httpd
TCP 0 0 0.0.0.0:48054 0.0.0.0:* LISTEN 5386/java
One-time cleanup of 80-port-consuming programs
Lsof-i: 80|grep-v "PID" |awk ' {print ' kill-9 ', $ $} ' |sh
Manually terminate the run of the process
Kill 5014
Can be forced to terminate if not terminated
Kill-9 5014
Start a service: Systemctl start Firewalld.service
Close a service: Systemctl stop Firewalld.service
Restart a service: Systemctl restart Firewalld.service
Displays the status of a service: Systemctl status Firewalld.service
Enable a service at boot: Systemctl enable Firewalld.service
Disable a service at boot: systemctl disable Firewalld.service
Check if the service is booting: Systemctl is-enabled firewalld.service
To view a list of services that have been started: Systemctl List-unit-files|grep enabled
To view a list of services that failed to start: Systemctl--failed
Common commands
Firewall-cmd--state # #查看防火墙状态, whether it's running
Firewall-cmd--reload # #重新载入配置, such as after adding a rule, you need to execute this command
Firewall-cmd--get-zones # #列出支持的zone
Firewall-cmd--get-services # #列出支持的服务, the service in the list is released
Firewall-cmd--query-service FTP # #查看ftp服务是否支持, return yes or no
Firewall-cmd--add-service=ftp # #临时开放ftp服务
Firewall-cmd--add-service=ftp--permanent # #永久开放ftp服务
Firewall-cmd--remove-service=ftp--permanent # #永久移除ftp服务
Firewall-cmd--add-port=80/tcp--permanent # #永久添加80端口
Iptables-l-N # #查看规则, this command is the same as Iptables
Man Firewall-cmd # #查看帮助
Since then, all configurations have been completed!
Ref: 80144890
80207918#commentbox
Source Installation Method Reference 80571961
Install MySQL 8.0.11 (CentOS 7.4 system) under Linux