1, install the configuration MySQL: This article installs the system is Centos6.3:
The code is as follows |
Copy Code |
Yum List MySQL # see if there are any packages installed Yum install MySQL # install MySQL client Yum List Mysql-server # to see if there are any packages installed Yum Install mysql-server # install MySQL server side #安装过后需要启动mysql服务 Service mysqld start #或者/etc/init.d/mysqld start # after startup, you need to create a root administrator for MySQL: Mysqladmin-u Root Password 123456 #后我们就可以通过以下连接mysql, go to the MySQL command line: Mysql-u root-p #回车后, you can enter the password #查看 MySQL Installation location Whereis MySQL |
2, MySQL configuration (common settings, highly recommended):
The code is as follows |
Copy Code |
#修改linux服务器下Mysql的设置需要用root登录系统后, Vi/etc/my.cnf Add after #在 [mysqld] Lower_case_table_names=1
|
#重启MYSQL服务, doing so will not differentiate the case of table names.
3. Data import:
The code is as follows |
Copy Code |
#需要一台windows机器, install navicat for MySQL #setup #关闭centos系统的防火墙 #CentOS下开启mysql远程连接, Remote Management database Grant all privileges in *.* to ' root ' @ '% ' identified by ' ebiz ' with GRANT option; #说明: In Windows and Mac OS X, the default value for Lower_case_tables_name is 1. |
4, the database automatic backup, through NAVICAT for MySQL automatic backup database, many online:
5, CentOS under the export data:
Mysqldump-u User name-p password database name > exported file name
The code is as follows |
Copy Code |
Mysqldump-u root-pebiz eblog >/home/soft/mysqlbak.sql |
Export a table
Mysqldump-u user name-P database name Table name > exported file name
Export a database structure
Mysqldump-u username-p-d--add-drop-table Database name > exported file name
6. Import data:
Create database Eblog character set UTF8;
Common source Commands
Enter the MySQL database console,
such as Mysql-u root-p
Mysql>use Database
Then use the source command, followed by the script file (such as the. SQL used here)
The code is as follows |
Copy Code |
Mysql>source/home/soft/mysqlbak.sql |
7, automatic backup, and upload to the designated FTP offsite backup:
The code is as follows |
Copy Code |
Rm-rf/home/mysqlbak/*.gz #删除gz文件 Date_str= ' Date +%y%m%d ' Cd/home/mysqlbak Mysqldump-h localhost-u Root--password=ebiz-r-e-e --max_allowed_packet=1048576--net_buffer_length=16384 Eblog | gzip >/home/mysqlbak/eblog_$date_str.sql.gz
Deldate= ' date-d -5day +%y%m%d ' #删除ftp服务器空间5天前的备份 Ftp-n 8.8.8.8 <<eof User Ftpuser FTPPassword Binary Lcd/home/mysqlbak Prompt Mput eblog_$date_str.sql.gz Mdelete eblog_$deldate.sql.gz Close Bye Eof<strong></strong> |
8, set the timing task
code is as follows |
copy code |
4 * * Roo T/HOME/FILESBAK/FILESBAK.SH 3 * * root/home/mysqlbak/mysqlbak.sh |