Install mysql database in CentOS

Source: Internet
Author: User

Install mysql database in CentOS
Detach original database

1. Check whether the system has installed the database.

Rpm-qa | grepmysql

2. Uninstall the original database

Rpm-emysql // normal deletion Mode
Rpm-e -- nodepsmysql // strong deletion mode. If you are prompted to delete other dependent files when using the command above, you can use this command to forcibly delete the files.
Use yum to install the database

1. query the database version provided by yum.

yumlist|grepmysql

2. Install the database

Yum install-y mysql-server mysql-deve

3. view the installed database version

rpm-qimysql-server
4. Start the database
4.1、servicemysqldstart
4.2、
If the 4.1 command cannot be started: mysql: unrecognizedservice
Usage:
/etc/rc.d/init.d/mysqldstart
Modify file permissions
chmod755/etc/rc.d/init.d/mysqld
You can use:
servicemysqldstart
Start
5. Check whether the database is started.
chkconfig--list|grepmysqld
6. Set startup
chkconfigmysqldon

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

/usr/bin/mysqladmin-urootpassword'new-password'

Or

mysqladmin-urootpassword'root'
Mysql configuration file 1, /Etc/my. cnf this 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/mysql database file storage location

[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/logmysql database log output storage location

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.