Uninstalling, installing, and configuring Mysql Databases in centos

Source: Internet
Author: User
Like Windows Server 2008 and, the SQL Server database is installed, and the mysql database is installed in linux. The first version of the Mysql database is released on Linux. I. mysql introduction MySQL is a relational database management system developed by MySQLAB in Sweden.

For example, in Windows server, the SQL Server database is installed. in linux, the mysql database is installed, and the first version of the Mysql database is released on Linux. I. mysql introduction MySQL is a relational database management system developed by MySQL AB in Sweden. It currently belongs to Oracle

For example, in Windows server, the SQL Server database is installed. in linux, the mysql database is installed, and the first version of the Mysql database is released on Linux.

I. mysql Introduction

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.

After installing the mysql database on Linux, we can download the rpm package of the mysql database from its official website. # downloads. You can download the corresponding database files based on your operating system, the latest version is 5.6.10.

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 The MySQL database: WARNING: The host 'xiaoluo 'cocould 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, shocould 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

Stronugly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon:

Cd/usr;/usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

Mysql-test-run.pl for cd/usr/mysql-test; perl

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 | grep mysqld

Mysqld 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 | grep mysql

Mysqld 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

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.