In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
Linux how to install MySQL5.7 and rights management, in view of this problem, this article introduces the corresponding analysis and solutions in detail, hoping to help more partners who want to solve this problem to find a more simple and easy way.
Decompress tar-xvf mysql-5.7.26-linux-glibc2.12-x86_64.tar
Create mysql user groups and users and modify permissions groupadd mysqluseradd-r-g mysql mysql
Create a data directory and grant permissions
Mkdir-p / data/mysql # create directory chown mysql:mysql-R / data/mysql # Grant permissions
Configure my.cnf
Vim / etc/my.cnf
The contents are as follows
[mysqld] bind-address=0.0.0.0port=3306user=mysql#log_bin# enables binloglog-bin = mysql-bin# Select row mode binlog-format = ROWserver_id = 12345basedir=/usr/local/mysqldatadir=/data/mysqlsocket=/tmp/mysql.socklog-error=/data/mysql/mysql.errpid-file=/data/mysql/mysql.pid#character configcharacter_set_server=utf8mb4symbolic-links=0explicit_defaults_for_timestamp=true
Initialize the database
Enter the bin directory of mysql
Cd / usr/local/mysql/bin/
Initialization
. / mysqld-defaults-file=/etc/my.cnf-basedir=/usr/local/mysql/-datadir=/data/mysql/-user=mysql-initialize
View password
Cat / data/mysql/mysql.err
Start mysql and change the root password
First put the mysql.server into / etc/init.d/mysql
Cp / usr/local/mysql/support-files/mysql.server / etc/init.d/mysql
Start it!
Service mysql startps-ef | grep mysql
It means that mysql has been installed successfully!
Let's change the password
First log in to mysql, and the previous one is randomly generated.
. / mysql-u root-p # bin directory
Perform the following three steps, and then log in again.
SET PASSWORD = PASSWORD ('123456'); ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;FLUSH PRIVILEGES
If you use a remote connection at this time... You will find that you cannot connect.
The following three commands are mainly executed here (log in to the database first)
Use mysql # accesses the mysql library update user set host ='% 'where user =' root'; # so that root can access FLUSH PRIVILEGES; # refresh from any host
Ok!!!! MySQL5.7 is ready to install. There are really many holes. But if we follow this process, we should be able to install it smoothly. Because I pretended it twice. )
If you do not want to use the mysql command in the bin directory every time, execute the following command
Ln-s / usr/local/mysql/bin/mysql / usr/binMySQL create user CREATE USER 'username'@'host' IDENTIFIED BY' password'
Username-description of the user name you will create:
Host-specify the host on which the user can log in. If localhost is available for local users, if you want the user to log in from any remote host, you can use the wildcard%.
Password-the login password of the user. The password can be empty. If it is empty, the user can log in to the server without a password.
Example:
CREATE USER 'javacui'@'localhost' IDENTIFIED BY' 123456; CREATE USER 'javacui'@'172.20.0.0/255.255.0.0' IDENDIFIED BY' 123456; CREATE USER 'javacui'@'%' IDENTIFIED BY' 123456; CREATE USER 'javacui'@'%' IDENTIFIED BY'; CREATE USER 'javacui'@'%'
Authorization
GRANT privileges ON databasename.tablename TO 'username'@'host'
Privileges-user's operation permissions, such as SELECT, INSERT, UPDATE, etc. (see the bottom of this article for a detailed list). If you want to grant the permissions, use the ALL description:
Databasename-Database name
Tablename- table name, which can be indicated by * if you want to grant the user the appropriate operation permissions on all databases and tables, such as *. *
Example:
GRANT SELECT, INSERT ON test.user TO 'javacui'@'%'; GRANT ALL ON *. * TO' javacui'@'%'
Note: a user authorized with the above command cannot authorize another user. If you want that user to be authorized, use the following command
GRANT privileges ON databasename.tablename TO 'username'@'host' WITH GRANT OPTION
Set and change user password
SET PASSWORD FOR 'username'@'host' = PASSWORD (' newpassword')
If it is currently used by the login user
SET PASSWORD = PASSWORD ("newpassword")
Revoke user rights
REVOKE privilege ON databasename.tablename FROM 'username'@'host'
Example description: privilege, databasename, tablename-same as the authorization section
REVOKE SELECT ON *. * FROM 'javacui'@'%'
If you authorize the user 'javacui'@'%' like this (or something similar): GRANT SELECT ON test.user TO' javacui'@'%', does not revoke the user's SELECT operation on the user table in the test database by using the REVOKE SELECT ON *. * FROM 'javacui'@'%'; command:
Conversely, if the authorization uses GRANT SELECT ON *. * TO 'javacui'@'%';, the REVOKE SELECT ON test.user FROM' javacui'@'%'; command cannot revoke the user's Select permissions on the user table in the test database.
Specific information can be viewed with the command SHOW GRANTS FOR 'javacui'@'%';
Delete user
DROP USER 'username'@'host'
Remember to refresh the database after operation
Flush privileges; 's answers to questions about how to install MySQL5.7 in Linux and rights management are shared here. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.
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.