Install mysql database in linux -- yum installation method, mysqlyum

Source: Internet
Author: User

Install mysql database in linux -- yum installation method, mysqlyum

Mysql database has multiple installation methods. This article only describes the most practical and quick installation method for mysql server on a Linux server.
1. Install yum on Linux Server (64-bit CentOS6.3)
All commands executed on the server are following #
1. Install mysql
# Yum install mysql-server mysql-devel-y
The last message is Complete! Indicates that the installation is successful.

2. Check whether the mysqld service is generated and set random start.
# Chkconfig -- list | grep mysql

Number Code server startup level. off indicates that the mysqld service is not started randomly, and on indicates that the service is started randomly.
We need to set the random start of mysqld and execute the following command to set
# Chkconfig mysqld on
The result is normal.
# Chkconfig -- list | grep mysql

3. Start the mysqld service
Run the following command to start the instance:
#/Etc/init. d/mysqld start
# Service mysqld start

After startup, ps to see if the process is up
# Ps-ef | grep mysql | grep-v grep
Root 1582 1 0 23:26 pts/0 00:00:00/bin/sh/usr/bin/mysqld_safe -- datadir =/var/lib/mysql -- socket =/var/lib/mysql. sock -- pid-file =/var/run/mysqld. pid -- basedir =/usr -- user = mysql
Mysql 1684 1582 1 00:00:00 pts/0/usr/libexec/mysqld -- basedir =/usr -- datadir =/var/lib/mysql -- user = mysql -- log-error =/var /log/mysqld. log -- pid-file =/var/run/mysqld. pid -- socket =/var/lib/mysql. sock
According to the process information, the mysql database data directory is/var/lib/mysql, and the error log file is/var/log/mysqld. log.

View All databases
# Cd/var/lib/mysql
# Ls-l

Two databases are found to come with mysql by default. How to manually create a database will be described in subsequent tutorials.

Check the occupied port. Port 3306 is used by default.
# Netstat-nutlp | grep mysql
Tcp 0 0 0.0.0.0: 3306 0.0.0.0: * LISTEN 1684/mysqld

4. Stop the mysqld service
Run the following command to stop the instance:
#/Etc/init. d/mysqld stop
# Service mysqld stop

5. Restart the mysqld service.
Run the following command to restart the instance:
#/Etc/init. d/mysqld restart
# Service mysqld srestart

6. Run the command line test to connect to mysql. You can directly manage the database in the command line later.
Run the command directly. mysql is installed in yum. The local root password is blank by default.
# Mysql

7. Set the initial password \ permission

Set a new password and grant permissions at the same time

Mysql> grant all on *. * to root @ '%' identified by 'youpassword ';

Refresh to make it take effect

Mysql> flush privileges;

Exit

Mysql> exit;

8. Log On again to check whether the new password and permissions take effect. mysql> [root @ nzp_redhat bin] # mysql-u root-pEnter password: "Enter the SET password"

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.