Three ways to install MySQL under Linux: RPM package installation, yum installation, source package installation

Source: Internet
Author: User

1 Installing the MySQL database server
Installation method One:
Querying the system's own database
Rpm-qa | Grep-i MySQL

Uninstall the query to all MySQL
RPM-E--nodeps mysql-libs-5.1.71-1.el6.x86_64
RPM-E--nodeps mysql-devel-5.1.71-1.el6.x86_64
RPM-E--nodeps mysql-5.1.71-1.el6.x86_64

Go to the folder where the RPM installation package is located, execute the command to install all RPM packages
RPM-IVH *.rpm


Installation Method Two:
Yum-y Install Mysql-server


MySQL configuration:
Set boot up
Chkconfig mysqld on

Start MySQL
Service mysqld Start

Initial no password login directly with user name
Mysql-uroot

Set password, user name: root, Password: toor
Mysql>set password for [email protected]=password (' Toor ');

Open remote access, user name: root, Password: Toor (this and the local root password can be set different, non-impact),% for any host
Mysql>grant all privileges on * * to ' root ' @ '% ' identified by ' Toor ' with GRANT option;

Refresh System Permissions
Mysql>flush privileges;

Quit MySQL
mysql>exit;

Description: The default engine for MySQL is MyISAM, and this engine does not support transactions. So to change the default engine, use a transaction-enabled engine InnoDB
View mysql5.1 's default storage engine method one
Mysql> show engines;

View mysql5.1 default storage engine method two
Mysql> Show variables like ' storage_engine ';
Mysql> exit;

Stop MySQL Database
Service Mysqld Stop

Modify/ETC/MY.CNF, add the following line to the bottom of the [Mysqld] class configuration
Default-storage-engine=innodb

Start MySQL
Service mysqld Start

Log in to see if the engine has been successfully modified, note: No spaces between-p and password
Mysql-uroot-ptoor
Mysql>show variables like ' storage_engine ';

Description: CentOS6.5 default is not open port, if you want to let External system access CentOS6.5 on the MySQL, must open MySQL port 3306
Modify the/etc/sysconfig/iptables, add the following line to the configuration file, followed by an HTTP connection, so add port 80
-A input-m state--state new-m tcp-p TCP--dport 3306-j ACCEPT
-A input-m state--state new-m tcp-p TCP--dport 80-j ACCEPT

Restart the firewall and if the remote connection is wrong, turn the firewall off and then on. You can do it.
Service Iptables Restart

Remotely log in to MySQL database using Navicat Lite
Create a new database with a name of WAF
Database name: WAF
Character set: UTF8--UTF-8 Unicode
Proofreading: Utf8_general_ci

Import the database table file Waf.sql, the table waflogs appears after the refresh, and this table records the log information of the WAF


Common commands:
Login with password, note: There can be no space between-p and password
Mysql-uroot-ptoor
Or, the following method, when entering the password is not visible
Mysql-uroot-p
Enter Password:

To view a database that already exists on the system
Mysql>show databases;

Select the database you want to use
Mysql>use Databasesname;

Delete the selected database
Mysql>drop database databasename;

To exit a connection to a database
Mysql>exit

To create a database named Test
Mysql>create database test01;

List the tables under the current database
Mysql>show tables;

Show Table Structure
Mysql>describe TableName;

Add Users
Mysql>create user ' test_user ' @ '% ' identified by ' test_user ';

Give new users test_user authorization so that he can log on locally
Mysql>grant all privileges on * * to ' test_user ' @ ' localhost ' identified by ' test_user ';

Give new users test_user authorization so that he can log in from outside
Mysql>grant all privileges on * * to ' test_user ' @ '% ' identified by ' test_user ';

Note: The left side is the username, the right side is the domain name, the IP and%, the domain name that can access MySQL and ip,% means that any external address can be accessed.
Mysql>select User,host,password from Mysql.user;

Refresh System Permissions
mysql> flush Privileges;


If MySQL does not start after the installation is complete, the workaround
MySQL service does not start, always start failed, because of the selinux reason, as long as the selinux shutdown is OK
Vim/etc/selinux/config
Change Selinux=enforcing to Selinux=disabled

Then reboot the system.
Reboot

The MySQL service cannot be started after SELinux is turned off, because the MySQL owner installed is root, a user MySQL is created when MySQL is installed, the owner of the/var/lib/mysql is changed to MySQL, and the command is executed.
Chown-r Mysql:mysql/var/lib/mysql

Execute Start MySQL Service
Service MySQL Start

If you want Python to support MySQL, you need to install the module

Installing the MySQL for Python module
Tar XF mysql-python-1.2.3.tar.gz
CD mysql-python-1.2.3
Python setup.py Build
Python setup.py Install

Installation method Three, the source code manually compiled installation
Tar XF cmake-3.1.2.tar.gz
CD cmake-3.1.2
./configure
Make
Make install
Tar XF mysql-5.5.20.tar.gz
CD mysql-5.5.20
CMake.
Make
Make install

Create MySQL users and user groups
Groupadd MySQL
Useradd-r-G MySQL MySQL
Cd/usr/local/mysql

Set the owner owner of all files in the current directory to root, and the owning group is MySQL
Chown-r Root:mysql.
Chown-r Mysql:mysql Data
To add the MySQL startup service to the system service
CP SUPPORT-FILES/MY-MEDIUM.CNF/ETC/MY.CNF

Create a table for the system database
Cd/usr/local/mysql
scripts/mysql_install_db--user=mysql
Setting environment variables
Vim/root/.bash_profile
Path= $PATH: $HOME/bin:/usr/local/mysql/bin:/usr/local/mysql/lib
Source/root/.bash_profile

Start MySQL
CP Support-files/mysql.server/etc/init.d/mysqld
Service mysqld Start
Service Mysqld Stop
Service mysqld Restart

Initial no password login directly with user name
Mysql-uroot

Set password, user name: root, Password: toor
Mysql>set password for [email protected]=password (' 123456 ');

Open remote access, user name: root, Password: Toor (this and the local root password can be set different, non-impact),% for any host
Mysql>grant all privileges on * * to ' root ' @ '% ' identified by ' 123456 ' with GRANT option;

Refresh System Permissions
Mysql>flush privileges;

Quit MySQL
mysql>exit;

Description: The default engine for MySQL is MyISAM, and this engine does not support transactions. So to change the default engine, use a transaction-enabled engine InnoDB
View mysql5.1 's default storage engine method one
Mysql> show engines;

View mysql5.1 default storage engine method two
Mysql> Show variables like ' storage_engine ';
Mysql> exit;

Stop MySQL Database
Service Mysqld Stop

Modify/ETC/MY.CNF, add the following line to the bottom of the [Mysqld] class configuration
Default-storage-engine=innodb

Start MySQL
Service mysqld Start

Log in to see if the engine has been successfully modified, note: No spaces between-p and password
mysql-uroot-p123456
Mysql>show variables like ' storage_engine ';

Three ways to install MySQL under Linux: RPM package installation, yum installation, source package installation

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.