Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install mysql and set up remote access in centos system

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

How do I install mysql and set up remote access on a centos system? I believe that many inexperienced people are at a loss about this, so this article summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

1. Download the repo source for mysql

$wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

two。 Install the mysql-community-release-el7-5.noarch.rpm package

$sudo rpm-ivh mysql-community-release-el7-5.noarch.rpm

After installing this package, you will get two yum repo sources for mysql: / etc/yum.repos.d/mysql-community.repo,/etc/yum.repos.d/mysql-community-source.repo.

3. Install mysql

$sudo yum install mysql-server

It is OK to install according to the prompts, but there is no password after the installation is completed, so you need to reset the password.

4. Reset mysql password

$mysql-u root

It is possible to report such an error when logging in: ERROR 2002 (HY000): Can't connect to local MySQL server through socket'/ var/lib/mysql/mysql.sock' (2) due to an access problem with / var/lib/mysql. The following command changes the owner of / var/lib/mysql to the current user:

$sudo chown-R root:root / var/lib/mysql

Restart the mysql service

$service mysqld restart

Next, log in to reset the password:

Enter $mysql-u root / / directly enter the mysql console mysql > use mysql;mysql > update user set password=password ('123456') where user='root';mysql > exit

Mysql for security, users are only allowed to log in locally by default, but in this case, you still need to use users to connect remotely, so in order to make them remotely, you need to do the following:

1. Allow root users to log in remotely anywhere and have any operation permissions for all libraries, as follows:

Use the root user to log in to mysql:mysql-u root-p "youpassword" for authorization operation on this machine: mysql > GRANT ALL PRIVILEGES ON *. * TO 'root'@'%' IDENTIFIED BY' youpassword' WITH GRANT OPTION; overload authorization table: FLUSH PRIVILEGES; exit mysql database: exit

2. Allow root users to log in remotely from a specific IP and have any operation permissions for all libraries, as follows:

First use the root user to log in to mysql:mysql-u root-p "youpassword" to authorize the operation: GRANT ALL PRIVILEGES ON *. * TO root@ "172.16.16.152" IDENTIFIED BY "youpassword" WITH GRANT OPTION; overload authorization table: FLUSH PRIVILEGES; exit mysql database: exit

3. Allow root users to log in remotely from a specific IP and have all library-specific operation permissions, as follows:

First use the root user to log in to mysql:mysql-u root-p "youpassword" for authorization operation: GRANT select,insert,update,delete ON *. * TO root@ "172.16.16.152" IDENTIFIED BY "youpassword"; reload authorization table: FLUSH PRIVILEGES; exit mysql database: exit

4. To delete a user authorization, you need to use the REVOKE command. The specific command format is as follows:

REVOKE privileges ON database [. Table name] specific instance of FROM user-name;, first log in to mysql:mysql-u root-p "youpassword" to perform authorization operation: GRANT select,insert,update,delete ON TEST-DB TO test-user@ "172.16.16.152" IDENTIFIED BY "youpassword", and then delete authorization operation: REVOKE all on TEST-DB from test-user * * Note: this operation only removes the user's authorization for TEST-DB, but the "test-user" user still exists. Finally, clear the user from the user table: DELETE FROM user WHERE user= "test-user"; reload authorization table: FLUSH PRIVILEGES; exit mysql database: exit

5. Detailed classification of MYSQL permissions:

Global administrative permissions: FILE: read and write files on the MySQL server. PROCESS: displays or kills service threads that belong to other users. RELOAD: reload access control tables, refresh logs, etc. SHUTDOWN: turn off the MySQL service. Database / data table / data column permissions: ALTER: modify existing data tables (such as add / delete columns) and indexes. CREATE: create a new database or data table. DELETE: deletes the record of the table. DROP: delete a data table or database. INDEX: create or delete an index. INSERT: add the record of the table. SELECT: show / search the records of the table. UPDATE: modifies records that already exist in the table. Special permissions: ALL: allow to do anything (like root). USAGE: only login is allowed-nothing else is allowed. After reading the above, have you mastered how to install mysql and set up remote access in the centos system? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report