In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Prepare for
The environmental information of this article:
Software version CentOSCentOS 7.4MySQL8.0.x
Update all packages of the system before installation
Sudo yum update
Installation
1. Add Yum package
Wget https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm# or wget http://repo.mysql.com/mysql80-community-release-el7-1.noarch.rpmsudo yum updatesudo rpm-ivh mysql80-community-release-el7-1.noarch.rpm
Note: the latest rpm package name can be found on the official website.
two。 Install MySQL
# install sudo yum-y install mysql-community-server# to start the daemon process sudo systemctl start mysqld# view status sudo systemctl status mysqld# view version mysql- V
After installation, MySQL starts automatically when the system starts, and if you don't want it to start automatically, you can turn it off using systemctl disable mysqld.
3. Modify the password
During MySQL installation, a temporary password is generated for the root user and saved in / var/log/mysqld.log. View with the following command:
Sudo grep 'temporary password' / var/log/mysqld.log
Enter the MySQL client to modify:
Mysql-u root-pALTER USER 'root'@'localhost' IDENTIFIED BY' your passowrd';# ALTER USER 'root'@ IDENTIFIED BY' your passowrd'
The password strength requirement is not less than 12 characters and must contain uppercase letters, lowercase letters, numbers and special characters.
3. MySQL security configuration
MySQL contains a security settings wizard script that you can use to modify security options.
Sudo mysql_secure_installation
After running, set the following items in turn:
1. Change the password of root account
two。 Password strength verification plug-in (recommended)
3. Remove anonymous users (recommended)
4. Disable remote login of root account
5. Remove test database (test)
Set up according to personal circumstances.
User permissions
1. Grant authority
# create a local user CREATE USER 'user'@'localhost' IDENTIFIED BY' password';# create a new remote user CREATE USER 'user'@'%' IDENTIFIED BY' password';# create a new database CREATE DATABASE test_db;# View user permission SHOW GRANTS FOR 'user'@'%';# give the user the specified database remote access permission GRANT ALL PRIVILEGES ON test_db.* TO' user'@'%' # give users remote access to all databases GRANT ALL PRIVILEGES ON. * TO 'user'@'%';# gives users local access to all databases GRANT ALL PRIVILEGES ON *. * TO' user'@'localhost';# refresh permission FLUSH PRIVILEGES
two。 Take back the authority
# withdraw permission REVOKE ALL PRIVILEGES ON *. * FROM 'test'@'%';# Delete Local user DROP USER' user'@'localhost';# Delete remote user DROP USER 'user'@'%';# Refresh permission FLUSH PRIVILEGES
3. Remote login
View user information in the mysql database:
Use mysql;select host, user, authentication_string, plugin from user
The host of root users in the table is localhost by default, and only local access is allowed. Authorize all permissions for the root user and set up remote access:
# authorize GRANT ALL ON *. * TO 'root'@'%';# to refresh FLUSH PRIVILEGES
The default password encryption method for root users is caching_sha2_password;, and many graphics client tools may not support this encryption authentication method, so they will report an error when connecting. Change the password again with the following command:
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY' your password'
The password encryption method of root is specified as mysql_native_password. If you want to change the default password encryption method, you can add a line to the / etc/my.cnf file:
Default-authentication-plugin=mysql_native_password
If the server has a firewall on, port 3306 needs to be opened.
Firewall-cmd-add-port=3306/tcp-permanentfirewall-cmd-reload
Note: if it is a CVM, some service providers (such as Aliyun) need to open the port to the console.
Modify character encoding
A character set is a set of symbols and encodings. Check the character set configuration:
Mysql > show variables like 'charac%' +-- +-- + | Variable_name | Value | +-- -+ | character_set_client | utf8mb4 | | character_set_connection | utf8mb4 | | character_set_database | utf8mb4 | | character_set_filesystem | binary | | character_set_results | utf8mb4 | | character_set_server | utf8mb4 | | character_set_system | utf8 | | character_sets_dir | / usr/share/mysql-8.0/charsets/ | + -- +
The effective rule of the character set is that Table inherits from Database,Database and inherits from Server. That is, only character_set_server can be set.
Proofreading rules are a set of rules used to compare characters in a character set. Check the proofreading rules:
Mysql > show character set like 'utf8%' +-+ | Charset | Description | Default collation | Maxlen | +- -+ | utf8 | UTF-8 Unicode | utf8_general_ci | 3 | | utf8mb4 | UTF-8 Unicode | utf8mb4_0900_ai_ci | 4 | +-+
Proofreading rule effective rule: if no proofing rule is set, the character set takes the default proofing rule, for example, the proofreading rule of utf8mb4 is utf8mb4_0900_ai_ci.
The MySQL 8 default character set has been changed to utf8mb4. In the previous version of MySQL, if the default character set is not utf8mb4, it is recommended to change it to utf8mb4.
Mb4 is most bytes 4. Why utf8mb4 and not utf8? MySQL supports utf8 encodings with a maximum character length of 3 bytes, and an exception will be inserted if a 4-byte wide character is encountered.
The following are the steps for the old version of MySQL to modify the character set to utf8mb4. MySQL 8.0 + does not need to be modified.
# View the configuration file location whereis my.cnf# open the file vi / etc/my.cnf
Add character encoding configuration items:
[client] default-character-set=utf8mb4 [mysqld] character-set-server=utf8mb4collation-server=utf8mb4_general_ci
Restart the MySQL service
Sudo systemctl restart mysqld
Use the MySQL command to check the character set configuration:
Show variables like 'charac%'
Referenc
Https://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/
Https://ken.io/note/centos-mysql8-setup
Recommended:
Interested friends can follow the editor's official Wechat account [programmer's thing], more web page production of special effects source code and learn practical information!
Summary
The above is the tutorial of installing MySQL 8 in CentOS 7 introduced by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply you in time. Thank you very much for your support to the website!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.