Knowledge about MySQL database operations in CentOS 6.5

Source: Internet
Author: User

Knowledge about MySQL database operations in CentOS 6.5

In CentOS 6.5, you can use Shell to modify the initial MySQL password, enable remote logon, and authorize remote logon users.

I recently wrote a Shell script for automated deployment. I need to use Shell to modify the initial MySQL password, enable remote logon, and authorize remote logon users,

After some searches and experiments, we can get the following commands to share with you:

Change the initial password:

Mysqladmin-uroot-pvyCE2UwSaqx3xofR password "123456"

Enable remote logon and authorize remote logon users:

Mysql-uroot-proot-e "grant all privileges on *. * to 'root' @ '%' identified by 'root' with grant option ;"

Make the authorization take effect immediately:

Mysql-uroot-proot-e "flush privileges ;"

Create, back up, and restore a MySQL database through Shell

Create a database:

Mysql-uroot-p123456-e "create database if not exists yourDatabaseName default charset utf8 COLLATE utf8_general_ci ;"

Back up the database:

Mysqldump-uroot-p123456 yourDatabaseName> c: \ backupFileName. dmp

Restore database:

Mysql-uroot-p123456 yourDatabaseName <c: \ backupFileName. dmp

Delete database:

Mysql-uroot-proot-e "drop database if exists exist _wisdom ;"

Display all databases on the server:

Mysql-uroot-proot-e "Show DATABASES ;"

MySQL5.0.37 passed the test!

Some problems occurred when restoring the database. Possible causes:

1. the backup file is exported in Windows;

2. the MySQL version for exporting the backup file is 5.0, and the target environment is 5.6;

-------------------------------------- Split line --------------------------------------

Install MySQL in Ubuntu 14.04

MySQL authoritative guide (original book version 2nd) Clear Chinese scan PDF

Ubuntu 14.04 LTS install LNMP Nginx \ PHP5 (PHP-FPM) \ MySQL

Build a MySQL Master/Slave server in Ubuntu 14.04

Build a highly available distributed MySQL cluster using Ubuntu 12.04 LTS

Install MySQL5.6 and Python-MySQLdb in the source code of Ubuntu 12.04

MySQL-5.5.38 universal binary Installation

-------------------------------------- Split line --------------------------------------

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.