Install mysql database in CentOS

Source: Internet
Author: User
Uninstall the original database 1. check whether the system has installed the database rpm-qa | grepmysql2. uninstall the original database rpm-emysql // general deletion mode rpm-e -- nodepsmysql // strong deletion mode, if you detach the original database

1. check whether the system has installed the database.

Rpm-qa | grep mysql

2. uninstall the original database

Rpm-e mysql // normal deletion mode
Rpm-e -- nodeps mysql // strong deletion mode. if the above command is used to delete other dependent files, you can use this command to forcibly delete them.
Use yum to install the database

1. query the database version provided by yum.

yum list | grep mysql

2. install the database

Yum install-y mysql-server mysql-deve

3. view the installed database version

rpm -qi mysql-server
4. start the database
4.1、service mysqld start
4.2、
If the 4.1 command cannot be started: mysql: unrecognized service
Usage:
/etc/rc.d/init.d/mysqld start
Modify file permissions
chmod 755 /etc/rc.d/init.d/mysqld
You can use:
service mysqld start
Start
5. check whether the database is started.
      chkconfig --list | grep mysqld
6. set startup
chkconfig mysqld on

 

7. set the initial password of the root user of the mysql database

        /usr/bin/mysqladmin -u root password 'new-password'

Or

        mysqladmin -u root password 'root'
Mysql configuration file 1, /Etc/my. cnfThis is the main configuration file of mysql.

Query content cat etc/my. cnf

[Root @ bogon Desktop] # cat/etc/my. cnf

[Mysqld]

Datadir =/var/lib/mysql

Socket =/var/lib/mysql. sock

User = mysql

# Disabling symbolic-links is recommendedto prevent assorted security risks

Symbolic-links = 0

 

[Mysqld_safe]

Log-error =/var/log/mysqld. log

Pid-file =/var/run/mysqld. pid

 

2, /Var/lib/mysqlDatabase file storage location of the mysql database

[Root @ bogon lib] # cd mysql/

[Root @ bogon mysql] # ll

Total 20488

-Rw ----. 1 mysql 10485760 Feb 1422: 52 ibdata1

-Rw ----. 1 mysql 5242880 Feb 14 ib_logfile0

-Rw ----. 1 mysql 5242880 Feb 14 ib_logfile1

Drwx ------. 2 mysql 4096 Feb 14 mysql

Srwxrwxrwx. 1 mysql 0 Feb 14 mysql. sock

Drwx ------. 2 mysql 4096 Feb 14 test

3./Var/logLog output location of the mysql database

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.