YUM installation and configuration of MySQL database in CentOS 6.5 system

1. Introduction to

MySQL MySQL is a relational database management system, developed by the Swedish MySQL AB company, and currently belongs to the Oracle company. MySQL is a relational database management system, relational databases keep data in different tables instead of keeping all the data in one big warehouse, which increases speed and improves flexibility. MySQL's SQL language is the most commonly used standardized language for accessing databases. MySQL software adopts a dual authorization policy (this entry "authorization policy"), which is divided into community edition and commercial edition. Due to its small size, fast speed, low total cost of ownership, especially open source The development of the website chooses MySQL as the website database. Due to the excellent performance of its community edition, it can form a good development environment with PHP and Apache.

To install the mysql database on Linux, we can go to its official website to download the rpm package of the mysql database, http://dev.mysql.com/downloads/mysql/5.6.html#downloads, you can download the corresponding database according to your own operating system The latest version of the database file is 5.6.10.

Here I use yum to install the mysql database. By installing in this way, we can install some services and jar packages related to mysql for us, so a lot of unnecessary troubles are saved! ! !

2. Uninstall the original mysql

because the mysql database is too popular on Linux, so the mainstream Linux system versions downloaded at present are basically integrated with the mysql database. We can use the following command to check whether our operating system is on The mysql database has been installed

[root@xiaoluo ~]# rpm -qa | grep mysql // This command will check whether the mysql database
has If so, we can use the rpm -e command or rpm -e --nodeps command to uninstall

[root@xiaoluo ~]# rpm -e mysql // Normal delete mode
[root@xiaoluo ~]# rpm -e --nodeps mysql // Force delete mode, if the above command is used to delete, it will prompt other dependent files, Then use this command to delete it forcefully.
After the deletion, we can use the rpm -qa | grep mysql command to check whether mysql has been uninstalled successfully! !

3. Install mysql through yum

I use yum to install the mysql database. First, we can enter the yum list | grep mysql command to view the downloadable version of the mysql database provided on yum:

[root@xiaoluo ~ ]# yum list | grep mysql
to get the downloadable version information of the mysql database on the yum server:



then we can install mysql mysql-server mysql-devel by entering the yum install -y mysql-server mysql mysql-devel command ( Note: When installing mysql, we do not install the mysql client, which means that the mysql database is installed. We also need to install the mysql-server server)

[root@xiaoluo ~]# yum install -y mysql-server mysql After waiting for a while for mysql-deve
, yum will help us choose the software required to install the mysql database and some other auxiliary software.



We found that installing the mysql database through yum saves a lot of unnecessary trouble. The following results indicate that the mysql database installation is successful



At this point, we can use the following command to check the version of mysql-server that was just installed

[root@xiaoluo ~]# rpm -qi mysql-server
The mysql-server we installed is not the latest version. If you want to try the latest version, then Just go to the mysql official website to download the rpm package and install it. At this point, our mysql database has been installed.

Fourth, the initialization and related

configuration of the mysql database After installing the mysql database, we will find that there will be 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 be initialized first, such as:

[root@xiaoluo ~]# service mysqld start to

initialize the MySQL database: WARNING: The host 'xiaoluo' could not be looked up with resolveip.
This probably means that your libc libraries are not 100 % compatible
with this binary MySQL version. The MySQL daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MySQL privileges !
Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue 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
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql -test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/bin/mysqlbug script!
                                                           [OK]
Starting mysqld: [OK]
At this point we will After seeing the mysql server for the first time, it will prompt a lot of information. The purpose is to initialize the mysql database. When we restart the mysql service again, it will not prompt so much information, such as:

[root@xiaoluo ~ ]# service mysqld restart
Stop mysqld: [OK]
Starting mysqld: [OK]
When we use the mysql database, we must start the mysqld service first. We can use the chkconfig --list | grep mysqld command to check whether the mysql service is automatically started at boot, such as:

[root@xiaoluo ~]# chkconfig --list | grep mysqld mysqld
0: close 1: close 2: close 3: close 4: close 5: close 6: close
chkconfig mysqld on command to set it to boot, so you don't have to manually start it every time

[root@xiaoluo ~]# chkconfig mysqld on
[root@xiaoluo ~]# chkconfig --list | grep mysql
mysqld 0: close 1: Disable 2: Enable 3: Enable 4: Enable 5: Enable 6: Disable
MySQL database After installation, there will only be one root administrator account, but the root account at this time has not set a password for it. When starting the mysql service, some initialization work of the database will be performed. In a large series of information output, we 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 Linux root account)

[root@xiaoluo ~]# mysqladmin -u root password 'root' // Set the password for the root account to root through this command.
At this point, we can log in to our mysql database through the mysql -u root -p command



Fifth , the main configuration file of mysql database

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

We can check some information of this file

[root@xiaoluo etc]# ls my.cnf

my.cnf
[root@ xiaoluo etc]# cat my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links= 0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
2./ver/lib/mysql Database file storage location of mysql database The database file of

our mysql database is usually stored in the directory /ver/lib/mysql

[root@xiaoluo ~]# cd /var/lib/mysql/

[root@xiaoluo mysql]# ls -l
total usage 20488
-rw-rw----. 1 mysql mysql 10485760 April 6 22:01 ibdata1
-rw -rw----.1 mysql mysql 5242880 Apr 6 22:01 ib_logfile0
-rw-rw----.1 mysql mysql 5242880 Apr 6 21:59 ib_logfile1
drwx------.2 mysql mysql 4096 April 6 21:59 mysql // These two are the default two database files when the mysql database is installed
srwxrwxrwx. 1 mysql mysql 0 April 6 22:01 mysql.sock
drwx------. 2 mysql mysql 4096 April 6 21:59 test // These two are the default two database files when the mysql database is installed.
We can create a database by ourselves 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.00 sec)
[root@xiaoluo mysql]# ls -l
total usage 20492
-rw-rw----. 1 mysql mysql 10485760 April 6 22:01 ibdata1
- rw-rw----.1 mysql mysql 5242880 Apr 6 22:01 ib_logfile0
-rw-rw----.1 mysql mysql 5242880 Apr 6 21:59 ib_logfile1
drwx------.2 mysql mysql 4096 Apr 6 21:59 mysql
srwxrwxrwx. 1 mysql mysql 0 Apr 6 22:01 mysql.sock
drwx------. 2 mysql mysql 4096 Apr 6 21:59 test
drwx------. 2 mysql mysql 4096 April 6 22:15 xiaoluo // This is the xiaoluo database we just created
[root@xiaoluo mysql]# cd xiaoluo/
[root@xiaoluo xiaoluo]# ls
db.opt
3./var/log mysql The log output storage location of the database

Some log outputs of our mysql database are stored in the directory /var/log

[root@xiaoluo xiaoluo]# cd

[root@xiaoluo ~]# cd /var/log
[root@xiaoluo log]# ls
amanda cron maillog-20130331 spice-vdagent.log
anaconda.ifcfg.log cron-20130331 mcelog spooler
anaconda.log cups messages spooler-20130331
anaconda.program.log dirsrv messages-20130331 sssd
anaconda.storage.log dmesg mysqld.log tallylog
anaconda.syslog d .old ntpstats tomcat6
anaconda.xlog dracut.log piranha wpa_supplicant.log
anaconda.yum.log gdm pm-powersave.log wtmp
audit httpd ppp Xorg.0.log
boot.log ibacm.log prelink Xorg.0.log.old
btmp lastlog sa Xorg.1.log
btmp-20130401 libvirt samba Xorg.2.log
cluster luci secure Xorg.9.log
ConsoleKit maillog secure-20130331 yum.log
The mysqld.log file is where we store some log information generated by our operations with the mysql database. By viewing the log file, we can get a lot of information from

it because our mysql database can be accessed through the network Yes, it is not a stand-alone database. 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 use the netstat -anp command to check whether the Linux system is listening on 3306. This port number:



As shown above, the port number 3306 monitored by the Linux system is our mysql database! ! ! !

Original address: http://www.server110.com/mysql/201312/3814.html

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327078325&siteId=291194637