Installation and configuration of SSD Cloud hosting–linode-mysql database

Source: Internet
Author: User
Tags mysql client cloud hosting hosting

Then the topic of the previous article: SSD Cloud Hosting-Linode configuration and deployment, building a Java environment

8. Installation and configuration of Mysql database

installation

Check if there is mysql inside yum;

yum list | grep mysql
I use a 64-bit system, so the x86_64 suffix is installed here;

yum -y install mysql-community-client.x86_64
yum -y install mysql-community-devel.x86_64
When cilent was installed, devel was already installed, and nothing was done here;

yum -y install mysql-community-server.x86_64
Very smooth, but also very fast;

At this time, we can check the version of the mysql-server just installed by the following command:

rpm -qi mysql-community-server
After we install the mysql database, we will find that there will be an additional mysqld service. This is our database service. We can start our mysql service by entering the service mysqld start command.

Note: If we start the mysql service for the first time, the mysql server will first perform the initial configuration, such as:

service mysqld start
mysql
ok, mysql started up;

Start mysql

When we use the mysql database, we must first start the mysqld service. We can use the systemctl list-unit-files | grep mysqld command to check whether the mysql service starts automatically after booting, such as:

Set to start at boot;

systemctl enable mysqld.service
systemctl list-unit-files | grep mysqld
After the mysql database is installed, there will be only one root administrator account, but the root account has not yet set a password for it, so we can use this command to set a password for our root account (note: this root account is mysql root account, not Linux root account);

mysqladmin -u root password ‘root’ // Use this command to set the password for the root account to root
At this point, we can log in to our mysql database through the mysql -u root -p command

Set the external network to allow access

1. Confirm whether 3306 is open to the outside world, mysql is not open to the external access function by default. The way to check is as follows:

netstat -an | grep 3306

tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN
As can be seen from the results, mysql port 3306 only listens to local connections, which prevents external IP access to the database. The modification method is as follows, enter the directory where the mysql configuration file is located (/etc/mysql/my.cnf ), Find the following content in the file:

\ # Instead of skip-networking the default is now to listen only on
\ # localhost which is more compatible and is not less secure.

bind-address = 127.0.0.1
Comment out bind-address or change it to the client host IP you want to use. If you do n’t, you do n’t have to.

2. Confirm whether the client user has access rights

In order to allow users who access the mysql client to have access rights, we can authorize users by:

Execute after connecting to mysql:

grant all privileges on *. * to the username created by @ "%" identified by "password";
flush privileges; #Refresh the content just now
#Format: grant permission on database name. Table name to user @ login host identified by "user password";
# @ Followed by the client IP address (or host name) to access mysql% represents any client, if you fill in localhost for local access (then the user cannot remotely access the mysql database).
#At the same time, you can also set whether to have remote access permissions for existing users. as follows:

use mysql;

update db set host = ‘%’ where user = ‘username’; (if written as host = localhost then this user does not have remote access rights)
FLUSH PRIVILEGES;
To view the results, execute:

select host, user, password from user;
SSD Cloud Hosting-Installation and Configuration of Linode-Mysql Database

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.