Install and configure the MySQL database in linux

Source: Internet
Author: User
Tags install perl

Install and configure the MySQL database in linux

1. decompress the file to the current directory.

Command: tar-zxvf mysql...tar.gz

2. Move the decompressed folder to the target directory and rename mysql

Command: mv mysql-version/usr/local/mysql

Add system mysql group and mysql user

Add a system mysql Group

sudo groupadd mysql

Add a mysql user

sudo useradd -r -g mysql mysql 

You can view the id mysql after adding it.

Then go to the/usr/local/mysql directory.

Set the permission of the mysql user group to operate on the folder

Command:chown -R mysql:mysql ./ 

Check whether/etc/my. cnf exists. If yes, delete it.

Command: ls/etc/my. cnf

DELETE command: rm/etc/my. cnf

Initialize Database

Command:./scripts/mysql_install_db --user=mysql

Note: If you run this command, the following error is reported:

Install the yum package

Command:yum -y install perl perl-devel 

After installation, run the database initialization command again.

Then go to the support-files folder.

Copy my-default.cnf to/etc and rename it my. cnf

Command:cp my-default.cnf /etc/my.cnf 

Copy the Startup File mysql. server to/etc/rc. d/init. d and rename it mysql.

Command:cp mysql.server /etc/rc.d/init.d/mysql 

Then configure mysql to start automatically

Go to the/etc/init. d directory.

Grant executable permissions to mysql

Command:chmod +x mysql

Add Service

Command:chkconfig --add mysql

View service list

Command:chkconfig --list

If you see mysql services, and all 3, 4, and 5 are on, the operation is successful. If it is off, Type

chkconfig --level 345 mysql on 

Restart your computer

Check the listener to check whether the service is started

Command:netstat -na |grep 3306

You can change the database remotely.

Authorized Operation

Command:grant all privileges on *.* to '%'@'%' identified by 'mypassword' with grant option; 

Refresh authorization

Flush privileges;

Remote connection

Delete other users

Summary

The above section describes how to install and unzip the MySQL database in linux. I hope it will be helpful to you. If you have any questions, please leave a message for me, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!

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.