The indissoluble bond between CentOS and MySQL

Source: Internet
Author: User

Environment Description:

Os:centos 6.3

First, MySQL uninstall:

Yum remove MySQL mysql-server mysql-libs compat-mysql51

Rm-rf/var/lib/mysql

Rm/etc/my.cnf

See if you have MySQL software:

Rpm-qa|grep MySQL

Some words continue to delete

Second, MySQL installation and start stop:

Installation:

You can do this by typing:

Yum install-y mysql-server MySQL mysql-devel

command to install MySQL mysql-server mysql-devel.

( note : Installing MySQL does not install the MySQL client is the equivalent of installing the MySQL database, but also need to install the Mysql-server server).

Start and restart:

View boot Status: Service mysqld status or/etc/init.d/mysql status

Start: Service mysqld start or/etc/init.d/mysql start

Restart: Service mysqld restart or/etc/init.d/mysql restart

STOP: Service mysqld stop or/etc/init.d/mysql stop

Third, MySQL common commands

3.1mysql Connection and exit

format:mysql-h host address-u user name-P user Password

1. Connect to MySQL on this computer:

# mysql-u Root-p

Enter after you are prompted to lose the password, note that the user can have a space before the name can be no space, but the password must be no space before you re-enter the password.

If you have just installed MySQL, superuser root is no password, so you can enter the direct return to MySQL, MySQL prompt is:

Mysql>

2. Connect to MySQL on the remote host. Assume that the remote host IP is: X, the user name is root, the password is 123456. Type the following command:

# mysql-h X-uroot-p 123456

3. Quit MySQL command:

# exit (Enter)

3.2mysql Modifying the root user password

Method 1: Use the Set password command

Mysql-u Root

mysql> SET PASSWORD for ' root ' @ ' localhost ' = PASSWORD (' Newpass ');

Method 2: Use Mysqladmin

mysqladmin-u root Password "Newpass"

If Root has already set a password, use the following method

mysqladmin-u root password Oldpass "Newpass"

Method 3: Edit the user table directly with update

Mysql-u Root

mysql> use MySQL;

mysql> UPDATE user SET Password = Password (' newpass ') WHERE user = ' root ';

mysql> FLUSH privileges;

This can be done when the root password is lost

Mysqld_safe--skip-grant-tables&

Mysql-u Root MySQL

mysql> UPDATE user SET Password=password ("New password") WHERE user= ' root ';

mysql> FLUSH privileges;

3.3mysql Create a new user

Create user username identified by ' password ';

3.4mysql User Authorization

GRANT all privileges the on database name. * to ' username ' @ '% ' identified by ' password ' with GRANT OPTION;

3.5 Backing up the database

1. Export the entire database, the export file by default exists in the current operating directory

# mysqldump-u User name-p database name > exported file name

# mysqldump-u user_name-p123456 database_name > Outfile_name.sql

2. Export a table

# mysqldump-u User name-P database name Table name > exported file name

# MYSQLDUMP-U USER_NAME-P database_name table_name > OUTFILE_NAME.SQL

3. Export a database structure

# mysqldump-u user_name-p-d–add-drop-table database_name > Outfile_name.sql

-D No data –add-drop-table add a drop table before each CREATE statement

4. Export with language parameters

# mysqldump-uroot-p–default-character-set=latin1–set-charset=gbk–skip-opt database_name > Outfile_name.sql


This article is from the "Justinlee" blog, make sure to keep this source http://justinlee.blog.51cto.com/9148265/1656875

CentOS's indissoluble bond with MySQL

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.