考完 RHCE 後偷懶了一段時間,該是回來的時候了。
因為工作的需要,曾經寫了網頁伺服器自動份備的 Script,目前因為要備份資料庫,又有新內容要產出了。
所以實戰還是最容易增進實力的方法。
安裝 Mysql 相關套件、啟動服務並進行設定
# yum install -y mysql mysql-server
# chkconfig mysqld on
# service mysqld start
# mysqladmin -u root password 12345 // 參考補充
# /usr/bin/mysql_secure_installation // 參考補充
# mysql -u root -p databse_name // -p 代表登入使用者有密碼保護
Enter password:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.1.66 Source distribution
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>show databases;
+--------------------+
| Database
+--------------------+
| information_schema
| mysql
+--------------------+
2 rows in set (0.00 sec)
mysql>create database backup_test; // 新增一個資料庫;刪除的指令drop database backup_test;
mysql>show databases;
+--------------------+
| Database
+--------------------+
| information_schema
| backup_test
| mysql
+--------------------+
2 rows in set (0.00 sec)
備份所有資料庫:連帳號也會一併備份
# mysqldump -u root -p --all-databases > /root/test.sql
匯入所有資料庫
# mysql -u root -p < /root/test.sql
補充:第一次啟動 MySql 時的狀態,會提醒使用者接下來要執行什麼指令。
# service mysqld start
Initializing MySQL database: Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/bin/mysqlbug script!
[ OK ]
Starting mysqld: [ OK ]
沒有留言:
張貼留言