Use yum in centos to install mysql and centosyum to install mysql

Source: Internet
Author: User
Tags dmesg

Use yum in centos to install mysql and centosyum to install mysql

Speaking of databases, we mostly think of relational databases, such as mysql, oracle, and sqlserver. These database software is very convenient to install on windows. If you want to install a database on Linux, we have to recommend the mysql database first, and the first version of the Mysql database is released on the Linux system.

MySQL is a relational database management system developed by MySQL AB in Sweden and currently belongs to Oracle. MySQL is an associated database management system that stores data in different tables rather than in a large warehouse. This increases the speed and flexibility. The SQL language of MySQL is the most commonly used standard language for accessing databases. MySQL adopts the dual Authorization Policy (this term "Authorization Policy"). It is divided into community edition and commercial edition. because of its small size, fast speed, and low total cost of ownership, especially open source code, MySQL is generally used as the website database for the development of small and medium-sized websites. Due to its superior performance, the Community edition works with PHP and Apache to form a good development environment.

Install the mysql database on Linux. You can download the rpm package of the mysql database from its official website.

Here I use yum to install the mysql database. Through this method, we can install mysql-related services and jar packages, this saves a lot of unnecessary trouble !!!

Ii. Uninstall the original mysql

Because mysql databases are too popular on Linux, the mainstream Linux system versions currently downloaded are basically integrated with mysql databases, run the following command to check whether the mysql database has been installed on the operating system:

[Root @ xiaoluo ~] # Rpm-qa | grep mysql // This command will check whether the mysql database has been installed on the Operating System

If yes, run the rpm-e command or the rpm-e -- nodeps command to uninstall it.

[Root @ xiaoluo ~] # Rpm-e mysql // normal deletion mode [root @ xiaoluo ~] # 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.

After deletion, run the rpm-qa | grep mysql command to check whether mysql has been uninstalled successfully !!

Iii. Install mysql through yum

I am using yum to install mysql databases. First, we can enter the yum list | grep mysql command to view the downloadable mysql database version on yum:

[Root @ xiaoluo ~] # Yum list | grep mysql

You can get the downloadable version of the mysql database on the yum server:

 

 

Then, run the yum install-y mysql-server mysql-devel command to install mysql-server mysql-devel (note: when installing mysql, We have installed the mysql database instead of the mysql client. We also need to install the mysql-server)

 

[Root @ xiaoluo ~] # Yum install-y mysql-server mysql-deve

 

After waiting for some time, yum will help us select the software required to install mysql database and other ancillary software.

 

 

We found that installing the mysql database using yum saves a lot of unnecessary trouble. When the following results appear, it indicates that the mysql database has been successfully installed.

 

 

In this case, run the following command to check the version of the newly installed mysql-server:

 

[Root @ xiaoluo ~] # Rpm-qi mysql-server

 

The mysql-server we installed is not the latest version. If you want to try the latest version, download the rpm package on the mysql official website, so far, our mysql database has been installed.

Iv. mysql database initialization and related configuration

After installing the mysql database, we will find 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 Initialization Configuration, for example:

[Root @ xiaoluo ~] # Service mysqld start initialize MySQL database: WARNING: The host 'xiaoluo 'cocould not be looked up with resolveip. this probably means that your libc libraries are not100 % compatiblewith this binary MySQL version. the MySQL daemon, mysqld, shocould worknormally with the exception that host name resolving will not work. this means that you shocould use IP addresses instead of hostnameswhen specifying MySQL privileges! Installing MySQL system tables... OKFilling help tables... OK To start mysqld at boottimeyou have to copysupport-files/mysql. server to the right place foryour system please remember to set a password for the MySQL root USER! To do so, start the server, thenissue the following commands: /usr/bin/mysqladmin-u root password 'new-password'/usr/bin/mysqladmin-u root-h xiaoluo password 'new-password' Alternatively you can run: /usr/bin/mysql_secure_installation whichwill also give you the option of removing the testdatabases and anonymous user created by default. this isstronugly recommendedforproduction servers. see the ma Nualfor moreinstructions. you can start the MySQL daemon with: cd/usr;/usr/bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.plcd/usr/mysql-test; perl mysql-test-run.pl Please report any problems with the/usr/bin/mysqlbug script! [OK] Starting mysqld: [OK]

 

At this time, we will see that a lot of information will be prompted after the mysql server is started for the first time. The purpose is to initialize the mysql database. When we restart the mysql service again, so much information will not be prompted, such:

 

[Root @ xiaoluo ~] # Service mysqld restart stop mysqld: [OK] Starting mysqld: [OK]

 

When using the mysql database, we have to start the mysqld service first. We can run the chkconfig -- list | grep mysqld command to check whether the mysql service is automatically started upon startup, for example:

 

[Root @ xiaoluo ~] # Chkconfig -- list | grepmysqldmysqld 0: Close 1: Close 2: Close 3: Close 4: Close 5: Close 6: Close

 

We found that the mysqld service is not automatically started when it is started. Of course, you can use the chkconfig mysqld on command to set it to boot, so that you do not need to start it manually every time.

 

[Root @ xiaoluo ~] # Chkconfig mysqld on [root @ xiaoluo ~] # Chkconfig -- list | grepmysqlmysqld 0: Disable 1: Disable 2: Enable 3: Enable 4: Enable 5: Enable 6: Disable

 

After the mysql database is installed, there will be only one root administrator account, but the root account has not set a password for it. When the mysql service is started for the first time, some database initialization will be performed, in a large string of output information, we can see such a line of information:

 

/Usr/bin/mysqladmin-u root password 'new-password' // set a password for the root account

 

So we can use this command to set a password for our root Account (note: this root account is the root account of mysql, not the root account of Linux)

 

[Root @ xiaoluo ~] # Mysqladmin-u root password 'root' // Use this command to set the password to root for the root account

 

Now we can log on to our mysql database using the mysql-u root-p command.

 

V. Main configuration files of the mysql database

1./etc/my. cnf this is the main configuration file of mysql.

We can check some information about this file.

[Root @ xiaoluo etc] # lsmy. cnfmy. cnf
[Root @ xiaoluo etc] # catmy. cnf [mysqld] datadir =/var/lib/mysqlsocket =/var/lib/mysql. sockuser = mysql # Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links = 0 [mysqld_safe] log-error =/var/log/mysqld. logpid-file =/var/run/mysqld. pid

2./var/lib/mysql database file storage location

The database files of our mysql database are usually stored in the/ver/lib/mysql directory.

 

[Root @ xiaoluo ~] # Cd/var/lib/mysql/[root @ xiaoluo mysql] # ls-l total usage 20488-rw-rw ----. 1 mysql 10485760 April 6 22:01 ibdata1-rw-rw ----. 1 mysql 5242880 April 6 22:01 ib_logfile0-rw-rw ----. 1 mysql 5242880 September 21: 59ib_logfile1drwx ------. 2 mysql 4096 21:59 mysql // these two are the default two database files srwxrwxrwx during mysql database installation. 1 mysql 0 April 6 22: 01mysql. sockdrwx ------. 2 mysql 4096 April 6 21:59 test // these two are the default two database files during mysql Database Installation

 

We can create a database to verify the storage location of the database file.

 

Create a database of our own: mysql> create database xiaoluo; Query OK, 1 row affected (0.00sec) [root @ xiaoluo mysql] # ls-l total usage 202.16-rw-rw ----. 1 mysql 10485760 April 6 22:01 ibdata1-rw-rw ----. 1 mysql 5242880 April 6 22:01 ib_logfile0-rw-rw ----. 1 mysql 5242880 September 21: 59ib_logfile1drwx ------. 2 mysql 4096 September 21: 59mysqlsrwxrwxrwx. 1 mysql 0 April 6 22: 01mysql. sockdrwx ------. 2 mysql 4096 April 6 21: 59testdrwx ------. 2 mysql 4096 22:15 xiaoluo // This is the xiaoluo database we just created [root @ xiaoluo mysql] # cd xiaoluo/[root @ xiaoluo] # lsdb. opt

3./var/log mysql database log output storage location

Some log output locations of our mysql database are stored in the/var/log directory.

[Root @ xiaoluo] # cd [root @ xiaoluo ~] # Cd/var/log [root @ xiaoluo log] # lsamanda cron maillog-20130331 spice-vdagent.loganaconda.ifcfg.log cron-20130331 mcelog spooleranaconda. log cups messages spooler-20130331anaconda.program.log dirsrv messages-20130331 sssdanaconda. storage. log dmesg mysqld. log tallyloganaconda. syslog dmesg. old ntpstats tomcat6anaconda. xlog dracut. log piranha wpa_supplicant.loganaconda.yum.log pm-powersave.log wtmpaudit httpd ppp Xorg.0.logboot. log ibacm. log prelink Xorg.0.log. oldbtmp lastlog sa Xorg.1.logbtmp-20130401 libvirt samba Xorg.2.logcluster luci secure Xorg.9.logConsoleKit maillog secure-20130331 yum. log

 

The mysqld. log file is the log information generated when we operate on the mysql database. By viewing this log file, we can obtain a lot of information.

 

Because our mysql database is accessible through the network, it is not a standalone database, and the protocol used is the TCP/IP protocol. We all know that the port number bound to the mysql database is 3306, so we can run the netstat-anp command to check whether the Linux system is listening for the port number 3306:

The result is as shown above. The port number 3306 monitored by Linux is our mysql database !!!!

 

This article details how to install the mysql database through yum in CentOS6.4 and perform basic configuration for the database. In the future Linux study, we will keep track of our experiences and experiences !!!!

Persistence is victory !!!!!!!!!!


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.