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